Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
Showing results for 
Search instead for 
Did you mean: 
Former Member

Hi All,

The Strategy Design Pattern is one of the commonly used Behavioral Design Patterns in OO world. I am interested here in blogging about how SAP is using this Design Pattern at work. The SAP has the BOPF framework and handles some of its core entities like Actions, Validations, Associations and Determinations polymorphically using this behavioral Design Pattern.

The main framework class /bobf/cl_frw controls the entry points to the encapsulated algorithms of the implementation classes of the interface /bobf/if_frw_action. As per definition a Strategy Design Pattern should adhere to the below set of rules -

(i)  The Client Class ( /bobf/cl_frw ) must not implement the interface ( /bobf/if_frw_action ).

(ii) There must be an instance attribute that should be TYPE REF TO the interface ( /bobf/if_frw_action ). The Class /bobf/cl_frw defines an instance attribute called mt_action based on the type tt_action and has a member called class which is TYPE REF TO the interface  ( /bobf/if_frw_action ).

(iii) There must be some logic or a setter method that sets the interface reference variable and points it to the specific defined implementation class. The interface reference variable here has a static type of /bobf/if_frw_action and the dynamic type is set to the specific implementation class at run-time.

READ TABLE mt_action WITH TABLE KEY act_key = <determined action key> INTO DATA(ls_action_class).

CREATE OBJECT ls_action_class-class TYPE (Implementation Class determined at run-time).

Therefore the strategy Design Pattern models the BOPF core entity Action and helps it in lending a polymorphic capability.

The same Design Pattern is at work for the other entities like Validations, Associations and Determinations.

 Thanks & Regards,