What is SOLID principle??

  • SOLID principles are the design principles that enable us manage most of the software design problem.
  • The terms SOLID is an acronym for five design principles intended to make software designs more understandable , flexible and maintainable
  • The principles are subset of many principles promoted by Robert C . Martin.



Why we use SOLID principles in our program??
  • To achieve reduction in complexity of code.
  • To increase readability, extensibility and maintenance.
  • To reduce error and implement reusability.
  • To achieve better testability.
  • To reduce tight coupling.
SOLID  acronym

      S: Single responsibility principle
      O:Open closed principle
      L:Liskov substitution principle 
      I:Interface segregation principle
     D:Dependency inversion principle 
     

Single responsibility principle.

“A class should have only one reason to  change”

Above principle means that a class have  only one responsibility and do only the task which it has been designed. 


What are the motivation of single responsibility principle??
  • Maintainability
  • Testability
  • Flexibility and Extensibility
  • Parallel Development
  • Loose coupling

Open -Closed principle.

"Should be able to extend a class behavior, without modifying it."

Above principle means that software entities (classes , modules) should be open for extension but closed for modification.

What are the benefits of open-closed principle??
  • Code maintainable and reusable.
  • Code more robust.



Why we need to follow open closed principle??
   If  not followed,
  • End up testing the entire functionality
  • QA Team need to test the entire flow
  • Costly process for the Organization.
  • Breaks the single responsibility as well.
  • Maintenance overheads increase on the classes.

Liskov substitution principle.

“Derived classes must be substitutable for their base classes.”

Above principle means that, that is a particular definition of a subtyping relation, called (strong) behavioral subtyping. Extension of Open Close principle. By using these principle we can validate that our abstraction are correct.

What are the benefits of   Liskov substitution principle??
  • Code more reusable.
  • Class hierarchies easy to understand.


Interface segregation principle.

“No client should be forced to depend on methods it does not use.”

Above principle means that one fat interface need to be split to many smaller and relevant interfaces so that clients can know about the interfaces that are relevant to them.  

What are the benefits of   Interface segregation principle?

  • Decouples system.
  • Code easy to refactor.

Dependency inversion principle.


“High-level modules should not depend on low-level modules. Both should depend on abstraction”

Above principle means that the interaction between high level and low level modules should be through of as an abstract interaction between them. When applying this principle it will reduce dependency on specific implementation and that make our code more reusable.

What are the benefits of  dependency inversion principle??

  • Reduce the coupling
  • Code more reusable.





Comments

Popular posts from this blog

Using OAuth 2.0 Authorization framework