Object oriented design : SOLID principles

Leave a comment

S : Single Task Responsibility : Each class does only one task well
O : Open/Close : Open for extension, closed for change
L : Liskov substitution principle : if a method can take a class as a parameter then it must be able to work by taking other subclasses of that class
I : Interface Segregation principle : Complex interface should be segregated
D : Dependency Inversion principle : It will be problematic if a class needs to depend on another class object to be created. Rather the required object should be provided when creating the that class object.

Also we need to make sure that, when we are ensuring one principle it doesn’t violate the other principles.

Leave a Reply