How should you section off your delegate (and datasource) methods? I have seen (so far) two ways that Apple does so in their templates:
- ‘Brief’ Format:
// MARK: - Table View
2. ‘SeparateComponentsWith ” ” ‘ Format:
// MARK: - Table view data source
What this misses:
- Firstly, the idea of having a plain-English pragma mark does not make sense – we should not be reading the pragma marks — not when there is an immediately recognizable heiroglyph such as UISomeAPIiKnowBySight.
- Secondly, this version…
// MARK: - UITableViewDataSource
…can be ⌘-clicked to take you to the docs and/or implementation of the API in question, which makes so much sense – put the instructions next to the tools in case they are needed.
So I change all boilerplate templates to conform their respective APIs. While those two reasons are not earth-shattering, they are compelling enough that I will not forget (or rather, can ‘re-derive’) which convention I adhere to, consistently. Consistency in coding is a very powerful contributor to readability, so sign me up.
So, who is going to let Apple know that they got this one wrong?