Friday, 6 July 2012

What is the Open-Close Principle?

Software entities like classes, modules and functions should be open for extension but closed for modifications.

Through proper modular design and abstractions you should construct your object hierarchy in such a way that when you need to implement a new feature that you should not have to make changes to the existing classes but rather extend them.

"Open Close Principle can be ensured by use of Abstract Classes and concrete classes for implementing their behavior. This will enforce having Concrete Classes extending Abstract Classes instead of changing them. Gang of Four Pattern examples include the Template Pattern and Strategy Pattern."

No comments:

Post a Comment