Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

What is OCP (Open Close Principle)? and how is it useful in software design?

Let Learn some basic concepts used in software design and development.

user-image
Question added by Mohammed Rizwan Afgani , Software Engineer, Team Lead , Prosoft e-Solutions (I) Pvt Ltd
Date Posted: 2013/07/03
Deleted user
by Deleted user

Open/Closed OOP Design Principle is one of the5 basic principles of OOP and Design presented in SOLID.
It implies that software entities such as Classes, Modules and Functions should be open for extension, but closed for modification.
e.g.
You can extend a class to add extra functionality, but without modifying the existing code.
I highly recommend reading the book "Head First - Design Patterns"

Zaid Rabab'a
by Zaid Rabab'a , Software Development Team Leader , Al-Safa Co. Ltd.

The Open Close Principle is design and writing of the code should be done in a way that new functionality should be added with minimum changes in the existing code.
The design should be done in a way to allow the adding of new functionality as new classes, keeping as much as possible existing code unchanged.
The name Open/Closed Principle has been used in two ways.
Both ways use inheritance to resolve the apparent dilemma, but the goals, techniques, and results are different.

Farhad Bheekoo
by Farhad Bheekoo , Senior Solution Architect , Woolworths NZ

This is the 'O' in 'S.O.L.I.D' principles .
It suggests that a class should only be Open for extension and Closed for modification.
This implies that when adding functionality to a class, that new functionaity should be added seamlessly without breaking or having to rewrite the class, in theory at least.
That being said, take a look at this article written by Jon Skeet - author of 'C# In Depth' - http://msmvps.com/blogs/jon_skeet/archive/2013/03/15/the-open-closed-principle-in-review.aspx

karim kamel
by karim kamel , Developer Support Engineer , Microsoft

The Open Close Principle is design and writing of the code should be done in a way that new functionality should be added with minimum changes in the existing code.

More Questions Like This