Atelier Clockwork

30

Trading Generated Code for Hand Written Code

I usually advocate that the more lines of code in a project, the more it costs down the line, so why would I advocate for having all layout be done in code instead of in interface builder?

Part of it is that working with constraints in both code and interface builder is a great way to make layout code impossible to understand. A second, larger, problem is that .xib and .storyboard files aren't fun to deal with using any kind of revision control software. If you open, without changing, anything using interface builder, there's a non-trivial chance that it will chance the file on you and it will need to be reset or committed.

Over the course of the project, the flow for creating and constraining views was refined several times, and what was initially a bit unwieldy has been streamlined. The one thing that I'd like to move towards doing it from scratch would be moving more of the constraints and subview setup into UIView subclasses rather than having the view controller doing most of that setup. It's less messy than it could be due to consistent use of categories inside classes, but I want smaller classes with better defined division of labor.

The next thing I'd like to look into would be using a storyboard for the high level navigation, but to keep all of the view design and low level details in code. Part of the desire for that is to reduce the amount of crosstalk between classes, and to have a visual map of the control flow. Getting views to preview and test using @IBDesignable would be nice, but even a series of blank screens with segues between them would be a good start.