cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP objects design patterns

Former Member
0 Kudos

hi all,

can any one send me the Design patterns used for ABAP objects programming in ABAP. eg mvc and sample code which uses the design patterns

cheers

senthil

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

hi ,

thanks for your reply . can some one mention what design pattern should be used in ABAP object Programming?

cheers

senthil

Peter_Inotai
Active Contributor
0 Kudos

I'm not familiar with design pattern, but this weblog might give you some idea:

/people/igor.barbaric/blog/2004/10/07/oo-abap-and-design-patterns--from-novice-to-success

Peter

nablan_umar
Active Contributor
0 Kudos

Senthil,

Look at sample Abap object program DEMO_ABAP_OBJECTS. You will see the design pattern of an Abap object program.

horst_keller
Product and Topic Expert
Product and Topic Expert
0 Kudos

Of course that program is not an object design pattern

(Its just a little ABAP Objects syntax demo that I wrote years ago

I don't know about a list of OO design patterns implemented in ABAP Objects.

A very simple one, a Singleton might look like this:

<b>* cl_singleton: Eager Variant

CLASS cl_singleton DEFINITION FINAL

CREATE PRIVATE.

PUBLIC SECTION.

CLASS-METHODS: class_constructor,

get_singleton RETURNING VALUE(singleton)

TYPE REF TO cl_singleton.

PRIVATE SECTION.

CLASS-DATA singleton TYPE REF TO cl_singleton.

ENDCLASS.

CLASS cl_singleton IMPLEMENTATION.

METHOD class_constructor.

CREATE OBJECT singleton.

ENDMETHOD.

METHOD get_singleton.

singleton = cl_singleton=>singleton.

ENDMETHOD.

ENDCLASS.

cl_singleton: Lazy Variant

CLASS cl_singleton DEFINITION FINAL

CREATE PRIVATE.

PUBLIC SECTION.

CLASS-METHODS get_singleton RETURNING VALUE(singleton)

TYPE REF TO cl_singleton.

PRIVATE SECTION.

CLASS-DATA singleton TYPE REF TO cl_singleton.

ENDCLASS.

CLASS cl_singleton IMPLEMENTATION.

METHOD get_singleton.

IF cl_singleton=>singleton IS INITIAL.

CREATE OBJECT cl_singleton=>singleton.

ENDIF.

singleton = cl_singleton=>singleton.

ENDMETHOD.

ENDCLASS.</b>

Former Member
0 Kudos

In what contexts are we terming them <b>easy variant</b> and <b>lazy variant</b> ?

Please correct me if I am wrong, but when you use the term Singleton(new to Objects) , it means that we can create only one instance per program ( if implementation and definition is done within an ABAP program ). What about, if the class is defined in SE24 ?

Regards,

Subramanian V.

former_member183804
Active Contributor
0 Kudos

Hello Subramanian,

I think Singleton means there is only one instance of a particular class within the runtime ( of an internal mode ). Its no difference wether the class is defined as global class-pool (se24) or a part of another main program.

Kind Regards

Klaus

Former Member
0 Kudos

Thanks for pointing that out.

Regards,

Subramanian V.

Peter_Inotai
Active Contributor
0 Kudos

MVC is not used Dynpro based ABAP...at least I never heard about it.

However MVC is can be used in BSP ( http://help.sap.com/saphelp_erp2004/helpdata/en/a6/38443ca607d75ce10000000a11402f/frameset.htm ) and will be used in WebDynpro for ABAP.

Peter