• Review: Mophie Juice Pack Air for iPhone 5

    One of the problems with any battery operated technology is that it is completely useless when the battery runs down. This, of course, has lead to a huge industry of aftermarket battery packs and charging mechanism for every gadget we use. While I'm not a huge user of my iPhone, I have found that when I travel, I am a little more cautious about using my phone for fear that I'll run out of juice on my phone and not be able to make an important call or will miss a message from home at the end of the day.

    Last year, before WWDC, I bought a Mophie Juice Pack Plus for my iPhone 4S and used it on all my trips. I don't travel all that often (on average about once a month), but I felt a lot better knowing that my phone would last all day. There are lots of tips for extending the battery life of a phone, but they all require futzing with settings and reducing the utility of the phone (one tip is to turn it off as the battery is getting low so that you can turn it on later to make an important call; it's hard to receive a call or check email when it is turned off!). The Mophie case was an excellent solution and served me well until I got my iPhone 5.

    I've travelled a few times with my iPhone 5 and haven't had much of a problem with battery life, but have topped it off before dinner on trips as it usually got quite low. When Mophie announced their latest cases for the iPhone 5, I knew I had to get one as WWDC is coming up again and I have a few more trips as well. In addition, now that I have a Pebble, I have to leave Bluetooth on all day which drains my battery a bit without doing anything. It was a no-brainer to order the case; it just was a matter of timing. I finally bit the bullet last week and with an estimated shipping time of 7-10 days, I figured I wouldn't receive it in time to give it a whirl on my next trip. However, Mophie's super fast shipping got it to me in a 3 days.

    I hadn't read the details on the Mophie site close enough to catch a small gotcha with the case; it wasn't until I heard the case as a "pick" on MacBreak Weekly that I learned of this gotcha. The pass through connector used for charging only charges and doesn't allow for syncing. As I don't use the case all the time and it is easy to remove, it isn't a huge issue.

    The other quirk is that the headphone connector is so far recessed and small that Mophie provides an extender cable. The Apple supplied headphones fit fine, but are a bit difficult to plug in and remove.

    I gave the case a test drive on my most recent trip, but somehow, my phone didn't drop below 15% even with talking on the phone for 1.5 hours, getting a bunch of email, receiving a few text messages and having Bluetooth on. So, while I was prepared to flip the switch on the case to recharge the battery, I didn't have to do it. Does this change my review? Well, not really, the only part I didn't test was "would it charge" and I have to assume it will otherwise I have a dud.

    Pros

    • It charges the battery.
    • It provides some protection on the side.

    Cons

    • Adds weight and bulk to the phone.
    • Pass through connector only charges and doesn't do data.
    • Pass through connector isn't a lightning connector. (I don't like micro USB as it is hard to insert correctly on the first try.)

    Summary

    If you find that your iPhone 5 drains its battery during the day, then having a battery case is extremely useful. Is it worth the $99 cost? That is really going to depend on your usage. I'm glad I bought it so that I don't have to worry about having a charge. While I have another external battery that lets me plug in a USB cable, it just isn't convenient. It is a lot cheaper, but when I've tried to use it, having it in my pocket with my phone and cable was too cumbersome to be a real solution. I won't use it all the time, but now I have it just in case. I'm sure that on longer trips it will come in handy. This first test trip ended up being a short day with me leaving my house around 6:30 am and arriving home around 7:00 pm.

  • Flaws in RESTful response codes

    Anyone that uses or develops APIs is familiar with REST. It is widely used and by some developers considered superior to other ways of doing APIs. Since REST was developed alongside the HTTP 1.1 spec, HTTP status codes are generally used for responses to REST calls.

    To me, it seems that using the standard HTTP response codes (a nice list is given here) is overloading a standard server response with the response of a query. While the spec says that for client errors (400 series errors), the response should contain the reason why in the response. I've looked at a lot of APIs and the best ones at handling errors return the error response inside of a successful 200 HTTP response. For instance, if you are creating an API for dealing with support tickets and you ask for a ticket ID that doesn't exist or you don't have permission to access, returning a 400 series error generally tells the client that something bad has happened when, in fact, the error is kind of minor. Embedding the error in the response seems like a better way to go.

    The problem, however, with embedding the error in the response is that the API developer has to come up with his own error codes and convey that to those that use the APIs. Many developers that implement APIs treat anything but a 200 series response as a complete failure and give up. So, the API developer has to make sure that the client implementors properly handle the responses. In general, I find it easier to have one set of parsing code and deal with the errors inside of a successful response.

    My argument, of course, is not very compelling as it is simply to swap one way of handling responses and errors with another. Last night, however, I came up with a potential argument that leads credence to what I'm saying. If there is a proxy server or a load balancer in front of the server, it could potentially return an error code which the client may not expect. Let's take the case where our support ticket server is behind a proxy server and the client requests a particular ticket. If the proxy server or load balancer is misconfigured and we make a request, the proxy server could return a 400 series error, even a 404 error. The client could interpret this as "the ticket doesn't exist". This may not be the case; the ticket could exist, but the proxy returned an error. A better way of handling this would be to use 200 series status codes when the request succeeds and embed the API error code inside of the response. If the proxy server returned a 400 series error, the client could always treat it as an error and wouldn't have to figure out if the support ticket really existed or not.

    In addition, the HTTP status codes are not granular enough for many APIs. This would require the API developer to have a secondary set of error codes that would be returned with the 400 series error codes anyway. If that is the case, why not just create one set of error codes and always return 200 series success codes unless something major has happened?

    I know that some of this may be confusing (it is crystal clear in my head), but it is worth some thought to consider the best way to handle response codes in APIs. Many people have opinions on this and may think that I have no idea what I'm talking about and HTTP response codes are perfectly fine for RESTful APIs.

  • Wrong definition of a pioneer?

    The other day I was looking at a website of a contracting company that specializes in mobile development. The site said that they were pioneers in the field. The site then had as its next line that the company was started in 2009. I normally think of pioneers as people who initially settle an area or who are first in a particular field. Unless my history of mobile is a little off, 2009 is a bit late to the party. If we just consider the "modern" era of mobile development that began with the iPhone and Android, they are still late as the iPhone was released in 2007 and the SDK in 2008.

    However, saying that mobile development began in 2007/2008 is doing a disservice to all the predecessors to iOS. PalmOS came out in 1996, the Newton came out in 1993, Windows CE came out in 1996 and the Psion was about the same time.

    I have no idea what meaning of pioneer this company had in mind, but they are certainly not pioneers in mobile applications. I've been writing mobile applications since 1994 when I first got a Newton (the Apple Personal Interactive Electronics group which made the Newton licensed my NotifyMail program and sent me a Newton MessagePad 110 in exchange for the license) and I don't consider myself a pioneer. I know a number of people that wrote mobile applications prior to this.

    If the company considers themselves pioneers, what do they call their developers that have 1-2 years of experience? Experts?

  • The wrong way to use asserts

    One of the ways programmers use to help ensure that inputs to methods are correct is to use asserts. Basically these will test conditions and stop execution if a test fails. By default, Xcode suppresses these asserts in release builds so that the code will simply continue.

    This past weekend, I was helping out on a project and found that the app stopped because of an assert indicating that a condition was not satisfied. As I looked into it closer, the programmer had put in asserts to test the results of what came back from the server. The author then didn't do runtime checks to validate the data, he simply assumed that if the assert passed, that the data was valid and continued. The problem is that, in this case, the server returned data that the code wasn't expecting, so in a release build, the code would have continued and then crashed because the data wasn't in the correct format.

    While I'm not a huge fan of asserts, they do have their place, just not here. The code should have done runtime checks and gracefully handle bad server data.

    I suspect that the author hadn't done enough client-server communication to know that servers return bad data more often than you'd expect. I've worked on so many projects where a simple server change causes clients to have hiccups, that I've gotten pretty good at defensively programming against this.

    If you choose to use asserts, make sure that you also use runtime checks and gracefully handle conditions that you test for in the asserts as the asserts go away in release builds.