Design Principle: Open/Closed Principle(OCP)

Design Principle

Open/Close Principle(OCP) says- Software entities(classes, modules, etc.), should be open for extension but closed for modification. It means that once a software entity is defined and implemented, we should not directly change it to add new functionality. Instead, we should extend it using inheritance or interfaces to accommodate new behavior or functionality.

Design Principle: Program to Interfaces, Not Implementations

Design Principle

The “Program to Interfaces, Not Implementations” principle is- Design your code to depend on interfaces, and avoid the dependency on concrete classes. The process is to define interfaces that specify required behavior. Classes then implement the interface and allow the system to extend and modify the implementation, without changing the dependent code.