As most of us know, Open/Closed Principle is a design principle while working with Object Oriented Programming. The wikipedia definition reads:
In object oriented programing, the open/closed principle states "software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification” that is, such an entity can allow its behaviour to be extended without modifying its source code. This is especially valuable in a production environment, where changes to source code may necessitate code reviews, unit tests, and other such procedures to qualify it for use in a product: code obeying the principle doesn't change when it is extended, and therefore needs no such effort.
This is a design principle that we generally follow in our day to day development cycle. Recently I have been doing a lot of code reviews and I have been working with the teams to ensure some good practices are being followed within the teams. To my surprise, there have been cases where I see the Open/Closed principle has been applied but the definition of open and closed have been reversed. I have seen implementations that are closed for extension but open for modifications. What this basically means is that the designs are flawed and there is a lot of re-work required to sort out the mess.
It is funny how life lets you chose your own interpretation of things !!!
No comments:
Post a Comment