Hi Varun Shukla
Here's about the pattern: https://en.wikipedia.org/wiki/Factory_method_pattern
Here's an example for ABAP: https://blogs.sap.com/2012/02/20/factory-pattern-in-abap-oo/
The example is complex, with configuration based on DB table, but it can also be as simple as
METHOD create_instance. IF iv_value = 'A'. CREATE OBJECT ro_instance TYPE lcl_a. ELSE. CREATE OBJECT ro_instance TYPE lcl_default. ENDIF. ENDMETHOD.
Kind regards,
Mateusz
Hi Varun Shukla,
https://www.abaptutorial.com/abap-factory-method-design-pattern/
Thanks & Regards
Akarsh
Hello Varun Shukla,
The factory method is most used for creating objects without any leverage to its instantiation technique. Interfaces and encapsulation concepts of OOABAP plays a vital role here.
You can follow the blog below which discusses the method in detail.
Regards!
Add a comment