S.O.L.I.D stands for:
- S - Single Responsibility Principle
- O - Open/Closed Principle
- L - Liskov Substitution Principle
- I - Interface Segregation Principle
- D - Dependency Inversion
Single responsibility principle
A class should have only a single responsibility (i.e. changes to only one part of the software's specification should be able to affect the specification of the class). For example purpose of Object, HashMap, Integer classes is very clear. HashMap should not be responsible to handle TreeMap's job and Integer class should not deal with Float class's job.
Open/closed principle
Should be open for extension, but closed for modification. This simply means that a class should be easily extendable without modifying the class itself.
Liskov substitution principle
Objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program. Mean interface should hold instance of all sub classes. Java uses this principle well.
Interface segregation principle
Many client-specific interfaces are better than one general-purpose interface. Means have more specific interfaces than a single interface for multipurpose.
Dependency inversion principle
Entities must depend on abstractions not on concretions. It states that the high level module must not depend on the low level module, but they should depend on abstractions.
Comments
Post a Comment