S O L I D Principle Rules in iOS

in ios •  6 years ago 
  • 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

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Hello! Your post has been resteemed and upvoted by @ilovecoding because we love coding! Keep up good work! Consider upvoting this comment to support the @ilovecoding and increase your future rewards! ^_^ Steem On!

Reply !stop to disable the comment. Thanks!