Rs /2017/much a…


Some principles of project maintainability:
  1. Write as little code as possible
  2. Don’t try to mess with the SDK and tools
    • Use design patterns that are already available in iOS frameworks, especially UIKit
    • MVC, Delegate, Dependency Injection, Target/Action
    • You extend MVC as Coordinators, and you process the data flow with coordinatingResponder
    • Let UIViewControllers do their job
    • Writing the UI layer in code violates Principle 1
    • Build UI with.storyboard /.xib whenever possible. Don’t code the UI unless you really have to
    • Instead of a.storyboard handling the data stream, it is just an optimized.xib, based on only 1-2 controllers
  3. Do not replace the system framework unless absolutely necessary
    • For example: PinLayout, FlexLayout, LayoutKit, Layout and so on replace The AutoLayout provided by Apple.
  4. Rely on Swift’s expressive ability
  5. Minimize third-party dependencies unless there is a clear need
    • Crypto, Keychain and other C language framework based on the package library
    • The Marshal JSON parsing library, which Swift 4 supports Codable, can also be tried without reliance
    • TinyConstraints micro AutoLayout library
  6. Adopt a consistent code style
    • Place code elements in the same place
    • Use a consistent order
    • Organize with as many consistent marks as possible
      • Delegates
      • Init / deinit
      • UI outlets
      • Dependencies (if any)
      • Local data source
      • Embedded Controllers (if any)
      • Notification tokens
      • Commented-out list of coordinatorResponder methods that particular file is overriding
      • Any additional stuff


When wondering whether you should write “smart” or “plain” code?

Remember! Be sure to keep it “straightforward.”