Monday, February 22, 2010

Replacement iPhone

Those Apple folks are pretty cool -- my iPhone 3G had developed a crack starting at the dock connector so I took it in to one of the Apple stores in town and they said it still was under warranty and replaced it with a brand new one (3G, no free upgrade to 3GS). I had researched the problem a bit before making the appointment to take it in and found that my iPhone was not the only one with that problem, but I was a bit skeptical that it would be as easy as it sounded to get it swapped out for a new one.

Sure, it shouldn't have cracked in the first place, but they definitely made good on it in my book. I assume the warranty doesn't reset with the new hardware (although maybe that assumption is wrong) but it doesn't matter, really -- I now have a brand new device that should last well beyond the original warranty period.

If you have an iPhone, go to the Apple Service and Repair site and enter your hardware serial number to see if you are covered. Don't assume that using a protective case prevents the crack from occurring; although I don't use a case, it doesn't seem to be related to anything a case could prevent from happening. My guess is that the problem is related to repeated use of the dock connector, and everyone uses that.

UPDATE 3/8/2010: The new iPhone had a dud battery -- it seemed like about 8 hours was all it was good for even with minimal active use (e.g. sitting on the night stand overnight). I watched it one day during the day and noticed that after about 6 hours following a full charge it would be down to 25%, again with minimal use.

Over the past weekend we were in the shopping center that has the Apple store where I got the replacement, so I stopped in to see if there was any chance of getting an appointment with the Genius Bar. This was a busy Saturday at a busy location, and the concierge said she had one spot, which was an hour and ten minutes away. That actually wasn't going to be a big problem because we had just gotten there, but then she looked in the Mac queue (she had looked previously in the iPhone queue) and saw that they had a slot coming up in 25 minutes, so she gave me that one instead, a nice touch.

At the appointed time a tech ran a piece of diagnostic software on the phone that seemed like it was more for show than anything (e.g. the tech noticed it had a handful of dropped calls, which seemed significant to him, although I don't see how that has anything to do with anything relating to the battery, but hey, who am I to complain?) and deemed it a dud. He grabbed out a new one from the back, swapped the SIM and did the paperwork, and we were out of there.

I am happy to report that the battery in this latest handset is working extremely well, holding a charge for a couple of days under normal use, and once again I felt like they had done right by me, even with the hassle of having to take the replacement unit back. That's good customer service.

Friday, February 12, 2010

Aggregate extension method in LINQ

It seems that I never stop finding new reasons to love LINQ and today I've found another: the Aggregate extension method.

Here's the scenario: we have a Silverlight application with a UIElement that binds to an IEnumerable of type string where the contents of each item is an error or validation message. There are times when instead of binding to the list I just want a concatenated string of all the items in the collection with a CRLF stuck on the end of each. Just for kicks I asked my friend Nick what at the time felt like a silly "how many convoluted ways can you think of to solve this simple programming problem, and how would you do it in LINQ?" question and, being the genius that he is, he suggested using the Aggregate extension method.

I already had a passing awareness of .Aggregate() but to be honest it hadn't occurred to me that it would be useful for something other than aggregating numbers, and at any rate I found it a bit unintuitive to use initially. It turns out, of course, that the accumulator can work on a series of strings just as easily as, say, ints, and it really couldn't be much simpler.

Here's how it looks as a C# Statement in LinqPad:

string[] words = { "foo", "bar", "ski" };
words.Aggregate(string.Empty, (seed, w) => seed + "\r\n" + w).Dump();

And in the Results pane:

foo
bar
ski

Pretty slick!