GitHawk
GitHawk copied to clipboard
Code structure: Adopt swift best-practices
trafficstars
Hello their contributors!
I've been looking into the code and saw that GitHawk suffers a bit from the MassiveViewController syndrom that many applications do.
If you e.g. have a look at Settings you'll notice that the ViewController declaration itself adopts several protocols. While is perfectly fine it creates some problems:
- Adopting the protocols inside the viewController declaration decreases the readability of the viewcontroller by bloating up the class itself.
- It tempts to create a lot of stored properties to handle states of these protocols (which might not be necessary) which can result in too many variables being declared and use -> less testability.
- Decreasted testability of the viewController itself.
I suggest to move the protocol adoption at least into extension declarations to keep the code more readable and have the Swift compiler detect unnecessary stored variables.
e.g. https://medium.com/swift2go/i-swift-part-1-organize-uiviewcontroller-classes-by-using-extensions-63957e517c65
For more information please have a look at:
- https://docs.swift.org/swift-book/LanguageGuide/Protocols.html (Adding Protocol Conformance with an Extension)
- https://docs.swift.org/swift-book/LanguageGuide/Extensions.html
Best wishes from southern germany.