This case study uses the example of a radio station playlist to demonstrate the performance benefits that you can experience when you create a custom iPhone application for an existing web service.
Playlister simply displays the last five songs played on Seattle radio station KEXP. If a given song on the playlist is available on Apple's iTunes Music Store, you can tap a button that will let you buy that song on your iPhone.
These screenshots show the list view and song detail view from the Playlister application:
The finished Playlister application is available for free at Apple's iTunes Music Store.
First, I'll state the general use case for the app:
When an iPhone is the only handy computer, I want a quick way to identify songs that were recently played on KEXP without a bunch of tapping and pinching at Mobile Safari.
Next I'll list some measurable problems with the status quo that will be solved after I ship the project.
That's it for requirements.
There are lots of cool features that could go into a radio playlist app, but the ones above address my favorite personal use case. And they will provide a nice example of the performance benefits possible with an iPhone App interface to an existing web service.
Now that I have my use case and some measurable feature requirements, it is time to build the Playlister web service.
This page of the Playlister case study describes the "cloud" web service that provides playlist data to the iPhone application.
I built the web service on the symfony PHP framework and deployed it on one of Dreamhost's private server instances.
The web service infrastructure for the Playlister application is what makes the ten-fold improvement in load times possible. It applies two simple approaches:
Regarding the first point, here is a diagram that depicts the flow of Playlister data on its way to the iPhone. The Playlister iPhone application would be very slow if it had to make separate requests to KEXP and Apple and then process that data. So the Playlister Web Service takes care of all that, allowing the iPhone application to get all the data it needs in a single, concise, request.
And the next image below is a graphic comparison of the amount of data sent from the Playlister web service versus the full playlist page to illustrate the second point from above. The page load time difference between these examples are small on a desktop or laptop computer, but it makes a huge difference for mobile applications where your audience may be using EDGE for network access. Even when your users have WiFi access, it taxes the limited resources of the iPhone to render complicated markup and Javascript, and that shows in slow page load times.
So I have a web service that is ready to provide quick-to-load nuggets of song data. Time to look at the iPhone application itself.
This page of the Playlister case study describes the iPhone application itself.
The Playlister Web Service has already taken care of all the resource-intensive work, so the Playlister iPhone application only has to receive the song data and put it on the screen.
Song data arrives at the iPhone in a lightweight format called JSON. All the application has to do is take each piece of song data from that JSON format and stick it into the appropriate iPhone UI element. This low overhead makes the application interface nice and snappy.
There is one part of the song detail view that has the potential to slow things down: the album cover art. A 100px by 100px album cover might weigh 16KB, which will load over EDGE in about 3 seconds. If I had to wait three seconds between tapping a song in the playlist and seeing the details, I would get impatient. But there is a solution for this slowdown. The iPhone SDK allows me to move the album art request to a separate processing thread. This means the song detail will load immediately when I tap a playlist entry, while the iPhone works on loading the album cover in the background. So my user experience stays snappy.
The diagram below shows the simple mapping between JSON data and iPhone UI elements. It also indicates the hyperlinked buttons that take you to destinations outside of the Playlister application.
And that's it!
Now I have a iPhone app that satisfies my general use case and all my specific requirements.
Thanks for reading the case study.
Please get in touch if you would like Arevit Solutions to build a custom iPhone application for your business.