About this document
OCP in Discount Calculation Examples by rajav99yt is a document available to read on EtoBox.
The Open/Closed Principle (OCP) states that software entities should be open for extension but closed for modification. The document provides a bad example of a discount calculator that violates OCP by requiring modifications to add new product types, and a good example that uses polymorphism to allow for easy extension without modifying existing code. The good example demonstrates how new discount strategies can be added dynamically, adhering to the OCP.
- Author
- rajav99yt
- Language
- EN