Slide 13
Slide 13 text
jgs
564 00001000
Definition
Software entities (functions, classes, modules, etc.) should be open for
extension but closed for modification.
OCP is all about achieving changes adding new code, not changing the old
code that already works.
Closure cannot be complete. There will always be some change against
which the entity is not closed. Thus, the closure must be strategic. As a
developer, make educated guesses about the likely kinds of changes that the
application could suffer over time.
OCP means that we do not want to modify the class, i.e., write code into a
class. Once you create a class and put that class in a production
environment, you do not want to touch that class.
OCP can be satisfied with a simple and effective heuristic: inheritance