Skip to content

Latest commit

 

History

History

Open_Close_Responsibility_Principle

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Main Idea:

"Software must be open for enhancement but closed for anyone who wants to modify the behavior or feature"

How To Tell If We are Violating the principle

When you go to the code and modify the existing implementation with a new one to work with a new requirement

e.g. Salesman only works with future potential Truck Buyers and the salesman tells you I want to now
work with Motorcycles Buyers. So you modify the code logic to now work for the potential Motorcycle 
Buyers.

How To Avoid Violating This Principle

Use Polymorphism or Inheritance