Chapter 14. Delivering quality Swift code
This chapter covers
- Documenting code via Quick Help
- Writing good comments that don’t distract
- How style isn’t too important
- Getting consistency and fewer bugs with SwiftLint
- Splitting up large classes in a Swifty way
- Reasoning about making types generic
Writing Swift code is fun, but in larger projects the ratio between writing and maintaining code shifts toward maintenance. Mature projects are where proper naming, code reusability, and documentation play an essential role. This chapter addresses these points to make programmers’ lives more comfortable when looking at code from a maintenance perspective.
This is the least code-centric chapter in this book, but one of the more important ones when working on projects in teams or when trying to pass a code assignment for a new job. It also covers some refactoring approaches to make your code more generic and reusable.
It starts with documentation—who doesn’t love to write it? I know I don’t. But you can really help other programmers get up to speed when you supply them with good examples, descriptions, reasoning, and requirements. You’ll see how to add documentation to code via the use of Quick Help.
Next, you’re going to handle when and how to add comments to your code and see how you can add, not distract, by surgically placing valuable comments. Comments aren’t Swift-centric, but they’re still an influential part of daily (Swift) programming.