Slim Down UIViewController

1. Separate Out Data Source and Other Protocols

Move Domain Logic into the Model

Creating the Store Class (a service layer/ repository)

Move Web Service Logic to the Model layer

Move View Code into the View Layer (increase reusability and simplicity)

Communication (maintainable)

2. Skinny Controller, Fat Model

Model Objects from Data Structures (Handles Loading & Saving of Model Objects, Encapsulates Caching and Lazy Fetching)

Reusable Views

ViewController as Conductor (Interface with Model, Handle User’s Input)

3. Avoid using UITableViewController, put lots of responsibilities into a single object which is both the datasource and delegate.

4. A view controller’s view does not exist until you access the UIViewController’s view property. (lazy view creation)

After the view has been created, the viewDidLoad() method is called. (the viewDidLoad() method is a perfect place for skinning purposes like colors and fonts, setting localized strings or performing the initial synchronization between model data and view)

 

Reference:

Light View Controllers

Unburdened ViewControllers

How to avoid big and clumsy UITableViewController on iOS

Decorator Pattern

Write High Quality View Controller

View Controller Programming Guide for iOS

Advertisements

About liyao13

Yao Li is a web and iOS developer, blogger and he has a passion for technology and business. In his blogs, he shares code snippets, tutorials, resources and notes to help people develop their skills. Donate $5 to him for a coffee with PayPal at About Me page and read more professional and interesting technical blog articles. Follow him @Yaoli0615 at Twitter to get latest tech updates.
This entry was posted in iOS, Uncategorized and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s