Object Oriented Design Principles (OODP): Open-Closed Principle(OCP)

By | December 20, 2009 | ABAP Objects, OO Design Principles | 4,066 | 2

Open-Closed Principle (OCP)

This is one of my published blogs on SCN – SAP Community Network.

The name itself sounds like contradicting – OPEN & CLOSE, but by definition, A module should be OPEN for extension but CLOSED for modification. The Open-Closed Principle (OCP) is one of the most important Design Principle. OCP originated from the work of by the Bertrand Meyer.

In simple words: We can add new features in the module without changing the existing code (CLOSED) but by adding new code (OPEN). By following this principle, we can make sure that by changing the code in the method we are not going to break existing functionality. Let us try to see it using the example.

Continue reading here:
Object Oriented Design Principles (OODP): Open-Closed Principle(OCP)

Like It? Share!!

Don't miss an Update

Get notified of the new post, right into your inbox

Naimesh Patel{271 articles}

I'm SAP ABAP Consultant for more than a decade. I like to experiment with ABAP especially OO. I have been SDN Top Contributor.
Follow :

Explore all of his 271 articles.

Load comments


  • Hey,

    I’ve just read your blog and sdn entry about OCP. Lately, as I was walking through some stanardcode I think I’ve might spotted something that uses this principle.
    Well, I guess you’ve already found some other code which uses this in the sap standard coding, nevertheless here is what I’ve found.

    Handles an object(REFACTORING_DISPLAY) either an interface or a class for refactoring purposes.

    In the Method DISPLAY it creates the deserved object which contains the interface IF_OO_REFACTORING_DISPLAY. Well the code in this method DISPLAY could be reduced to some less lines of code. Like following:

    create object refactoring_display type (l_deserved_type)
    imp_clif_name = clif_name
    imp_assistent = me
    imp_repid = repid
    imp_dynnr = dynnr
    clif_not_existing = 1
    others = 2

    if refactoring_display is bound.
    refactoring_display->display( ).

    to act more the way as you’ve posted in your sdn blog entry.


  • Hello jptschudy,

    Thanks for sharing your findings. There are lot of opportunities to implement various principles and improve the quality of the software.

    Lets hope, we observe more and more usage of Design Pattern and Design Principles in Std SAP delivered code.

    Naimesh Patel

Comments on this Post are now closed. If you have something important to share, you can always contact me.

You seem to be new here. Subscribe to stay connected.