Liskov Substitution Principle (LSP)
The Liskov Substitution Principle (LSP) states that objects of a superclass should be replaceable with objects of its subclass without altering the correctness of the program. This principle is crucial for ensuring that derived classes extend the behavior of the base class without introducing unexpected issues. Key Idea A subclass should: Behave in a way […]
Open/Closed Principle (OCP)
The Open/Closed Principle (OCP) states that a software module (class, function, or component) should be open for extension but closed for modification. This means that you should be able to add new functionality to a module without changing its existing code. OCP is one of the SOLID principles in object-oriented programming. Why Follow OCP? Avoid […]