Friday, June 7, 2013

Day 40: Retrospective

Now that I am once again focusing primarily on Android development this may be the end of the road for my crash course in iOS (at least for now). Here is a summary of some of the lessons learned during my brief experiment as an iOS user and developer.

1. Android and iOS are more alike than different.


Despite different hardware, operating system, language, and development environment ultimately both Android and iOS are mobile computing platforms. You still need to solve many of the same problems including resource management, network communication, and designing for a small screen.

Some aspects of iOS development have actually helped me become a better Android developer. Using the common delegate pattern on iOS has helped reinforce the value of extracting logic from my Android Activities and Fragments into objects with a proper Interface (Protocol).

Even the differences in syntax between Objective-C and Java, while significant at first, quickly fade into the background as you get used to all those square brackets.

2. The differences are significant.


Building a UI is very different on iOS. The technique most Android developers use is based on editing layouts in XML. In iOS UI editing is done graphically through Interface Builder or Storyboards. Or written purely in code. But there is really no good option for a declarative markup syntax since the code produced by the graphical tools is not human readable.

Navigation and integration are also drastically different on iOS. Android uses Intents to transition between screens within the same application or even to integrate with other applications on the device. In iOS transitions are a function of the graphical UI editor, or can be accomplished in code by keeping a reference to the various view controllers and manually adding/removing subviews from the root view controller. Integration with other applications is not possible in the same manner as Android but can still be accomplished to some extent using techniques like a custom URL scheme for deep links or a shared Pasteboard.

Storyboards in XCode

3. Everything is in the foreground.


As an iOS user and developer I could not get over the fact that almost everything must happen while the app is in the foreground. The end result is that many apps feel slow and stale as compared to their Android counterpart. Not being able to spin up a background service to periodically sync data or poll location means that each time you open an app you have to wait for it to fetch fresh data.

For example, each time I would receive a notification for new message in GMail on iOS I would start reading a preview of the message in the notification. Then I would open the GMail app and I would have to wait for the data to sync before I could continue reading the rest of the message. I guess I am spoiled on Android but this feels like bad UX. Making users wait to see the newest content is a waste of their time.

4. Test-driven development is alive and well on iOS.


Many times in the past I have heard from iOS developers that unit testing and TDD/BDD is either difficult or impossible. I'm not sure how much this has changed in recent versions of the OS, but in my experience testing on iOS is not only possible but the tools are even better than what is currently available on Android. While projects like Robolectric have improved the situation, Android still has a long way to go to enable efficient unit testing that is fully integrated with the platform.

On iOS you have a variety of testing frameworks available. During this experiment I successfully test-drove my code using OCUnit, Kiwi, and KIF. Other options include Cedar, Cucumber/Calabash, and UI Automation.

And iOS has the added advantage that running tests on the simulator is much faster than deploying to an Android emulator or device which means that even running integration and functional tests though the UI is quite fast comparatively.

For a sample test-driven iOS app check out Three the Hard Way (HelloTDDiOS).

Summary


Even though hands-on iOS development may not be something I am going to do professionally on a regular basis, increasing my literacy of Objective-C and my understanding of the platform has still been beneficial.

It has improved my vocabulary and comprehension in discussions with iOS developers. It has given me a better overall understanding of mobile ecosystems that span across multiple platforms. And it has prompted me to make an effort to work more closely with my iOS counterparts day-to-day because in the end we are solving many of the same problems.

Only Android does it a little bit betterAndroid wink


Big thanks to Matt Smollinger and Matthew Lim for their reviews and feedback on the draft of this post.