Slide 6
Slide 6 text
Open Closed Principle (OCP)
“Software entities (classes, modules, functions, etc.) should be open for extension, but closed for
modification.”
● All this means is that a class should be extendable without modifying the
class itself.
● Open for extension: new behaviour can be added to satisfy the new
requirements.
● Closed for modification: by extending the new behaviour we are not required
to modify the existing code.
● Use an interface, interfaces are your friend. Something conforming to an
interface makes it simple to code another implementation.