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
- 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.
- Open/Closed Principle: The Class should be Open for extension( i.e. Inheritance) but Closed for modification.
- 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
- 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.
- Dependency Inversion: Any Class should ASK for its dependencies instead of creating it.