S.O.L.I.D Design Principle.

 SOLID Design Principles Explained:

SOLID is one of the most used Design Principle in OOPS world. Its a mnemonic of below described words

  • Single Responsibility Principle
  • Open/Closed Principle
  • Liskov Substitution Principle
  • Interface Segregation Principle
  • Dependency Inversion

 

  1. Single Responsibility Principle: As the name says, every Class should have only one thing to do i.e. one Class should be responsible to execute or perform only on activity in any application. E.g  Controllers, DAOImpls, Validators, Utilities etc.
  2. Open/Closed Principle: The Class should be Open for extension( i.e. Inheritance) but Closed for modification.
  3. Liskov Substitution Principle: Any reference variable attribute of Class that uses pointers to Parent Class must be fully replaceable with other Child objects of that same Parent Class. Explained here
  4. Interface Segregation Principle: Clients should not be made to implements all the methods of any Interface. i.e. Instead of using one FAT Interface, better we distribute methods in different-2 Interfaces.
  5. Dependency Inversion: Any Class should ASK for its dependencies instead of creating it.