Refactoring Massive View Controllers

Harry Ng
2 min readOct 28, 2016

--

This is an unfinished journey, thus I am going to take this opportunity to keep some useful readings here.

Decoupling components

To build lighter view controllers, the first step is to decouple source codes into separate classes. In his article, Chris Eidhof suggests to refactor Data Source and Delegate into separate classes.

Generic View Controllers

In some situations, the display for several view controllers may be very similar. The difference is likely different models, or slightly different presentation details. One could create Generic View Controller to store the shared code base. R. Peres wrote a piece on how to create this.

Storyboard

In case you want to use the subclass of Generic View Controller or any other view, you will need special treatment in the app launch time. Apple Staff Eskimo showed case how to do it in a thread.

I also created a sample project for both iOS and macOS here.

--

--