This is one of my published blogs on SCN – SAP Community Network.
Definition:
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)
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.
The Class: CL_OO_REFACTORING_ASSISTENT
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)
exporting
imp_clif_name = clif_name
imp_assistent = me
imp_repid = repid
imp_dynnr = dynnr
exceptions
clif_not_existing = 1
others = 2
.
if refactoring_display is bound.
refactoring_display->display( ).
endif.
to act more the way as you’ve posted in your sdn blog entry.
Greetings
jptschudy
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.
Regards,
Naimesh Patel