Using Design Patterns in iOS App Development - dummies

Using Design Patterns in iOS App Development

By Neal Goldstein, Dave Wilson

When it comes to iOS app development, the framework is designed around certain programming paradigms, also known as design patterns. The design pattern is a model that your own code must be consistent with. The UIKit framework does a lot of the heavy lifting for you. That’s all well and good, but working with that framework is a little more complicated than just letting it do its work.

To understand how to take best advantage of the power of frameworks — or (better put), figuring out how the framework objects want to best use your code — you need to understand design patterns.

If you don’t understand them or if you try to work around them because you’re sure that you have a “better” way of doing things, your job will actually end up being much more difficult. (Developing software can be hard enough, so making your job more difficult is definitely something you want to avoid.)

Getting a handle on the basic design patterns that the framework uses (and expects) will help you develop an app that makes the best use of the framework. This means doing the least amount of work in the shortest amount of time.

The design patterns can help you to understand not only how to structure your code but also how the framework itself is structured. They describe relationships and interactions between classes or objects, as well as how responsibilities should be distributed among classes so that the iPad does what you want it to do.

In programming terms, a design pattern is a commonly used template that gives you a consistent way to get a particular task done.

To develop an iOS app, you need to be comfortable with the following basic design patterns:

  • Model-View-Controller (MVC)

  • Delegation

  • Block Objects

  • Target-Action

  • Managed Memory Model

Of these, the Model-View-Controller design pattern is the key to understanding how an iPad or iPhone app works.

Another basic design pattern exists as well: Threads and Concurrency. This pattern enables you to execute tasks concurrently (including the use of Grand Central Dispatch, that aiding-and-abetting feature introduced in OS X Snow Leopard for taking full advantage of all that processing power available, even on the smaller iPad and much smaller iPhone).