objc-guide icon indicating copy to clipboard operation
objc-guide copied to clipboard

Application Framework Anti-Patterns

Open markavitale opened this issue 5 years ago • 0 comments

Convention

  • Don't make assumptions about a reverse-dependency's implementation. AKA, don't assume NSApp or NSApp's delegate conforms to a given protocol (even checking for conformance is wrong, because you shouldn't know about
  • Provide a delegate property in this case, don't directly access the application delegate. The application delegate could be your delegate, but you shouldn't know or care, only the Application Delegate would know or care in that case.

Rationale

These types of reverse dependencies make it harder to refactor and reorganize code and make components inherently less reusable.

Example

TBD

markavitale avatar Jun 05 '20 05:06 markavitale