Reducing Boilerplate in iOS Development

Lately I have been thinking of ways to reduce boilerplate in Xcode. I use a lot of collection views and collection view cells. Can anyone help me out on how best to approach datasource and delegation boilerplates?

@codebendr Thanks very much for your question!

This is always the challenge of ANY programmer…reducing code in your project.

One of the nice things about iOS development using Swift is the ability to use extensions. By using extensions, I’m able to isolate the protocol methods for the delegates I implement. One other factor to consider for minimizing boilerplate code is to only implement those methods you need, and nothing else. For example, the only two methods that are required to be implemented for UITableViews is “cellForRowAtIndexPath” and “numberOfRowsInSection”.

The above are very basic suggestions to get started. For the more advanced developer, I would recommend learning some design patterns that can help you accomplish this. I would suggest getting our book on design patterns here.

I hope this helps!

All the best!

Thank you for this. I will purchase and read the book.

Regards.

This topic was automatically closed after 166 days. New replies are no longer allowed.