4th Street Bar Hive-Bar

Hive-Bar Powered by Hive beta-fdb5b5b

Community post

S O L I D Principle Rules in iOS

  • The Single Responsibility principle tells us to separate responsibilities. But to know what these responsibilities are, we have to look at the bigger picture of our app. The MVC pattern already helps us respect this principle. Its tree structure is a top down hierarchy. The view controllers, which embody the core behavior and flow of our app, are at the top;

  • the Open-Closed principle tells us to keep types open for extension when we add new functionality. You can spot violations of this principle by looking for long branching statements. You solve this by moving functionality down to lower level modules. This goes again in a top down fashion;

  • the Liskov Substitution Principle says that derived types must be substitutable for their base type. As we have seen, this is from the point of view of the code that uses such types. So it is again top-down;

  • the Interface Segregation Principle makes us split interfaces into small ones to avoid dependency between the clients of such interface. Here we look interfaces from the outside, from the point of view of a client. Top-down again;

  • the Dependency Inversion Principle is the one that most explicitly states its top-down approach. It says that high-level modules dictate the interfaces of low-level modules. These interfaces, in turn, dictate the structure of the code in the low-level modules.
    Source iOS Architect

4 upvotes $0.00

Replies (1)

Review before signing

Posting as . Signing with . Keychain permission: Posting. Hive Keychain will ask you to approve this action next.


  
Technical details

Operation fingerprint: