Skip to Content



I would like to introduce the basic concept of Object Oriented Design Pattern  “Program to an Interface, not an implementation” in our application.



To make the application in Part I more flexible, create an interface ZIF_DATA_EXCHANGE, with method signatures  GET_CUSTOMER_ID and SET_CUSTOMER_ID with customerid type string as parameter. The objective of the interface is to provide methods that will be implemented by the classes (controllers)  to exchange the data .  In our case all of the controllers are going to implement the interface depending on the method of data transfer.



Implement the interface in main.do, so that the methods in the interface are available for redefining in the controllers for implementation.



Now, consider the three methods of data transfer explained in PART I.



Method 1.



1.Create an attribute CUSTOMERID in main.do

2.Redefine methods SET_CUSTOMERID and GET_CUSTOMERID in main.do as below.



Now get the instance of the interface that was implemented in main.do and code to the interface as per Design Patterns.



3.     In DO_HANDLE_EVENT of LIST.Do capture the row selected event and set the parent controllers attribute CUSTOMERID with customer id of selected row by calling the interface method SET_CUSTOMERID implemented in main.do.







4.     In DO_INIT_ATTRIBUTES of details.do, get the customer id from parent controller that was set by the list selection event.







Get the customer details based on me->customerid to display in the page. 



Method 2. (Push Method)



The rowselect event in list.do accesses the implementation class in main.do and sets the attribute’s value in detail.do



Assumption is that the component id for details list is defined as ‘detail.

1.     Interface ZIF_DATA_EXCHANGE should be implemented in controllers main.do as shown.



In Details.do implement the interface method SET_CUSTOMERID  should be as shown below to set the customerid attribute in details.do controller.







Method 3. (Pull Method).



This is implemented in DO_INIT_ATTRIBUTES of details.do . Gets the attribute from list.do by using the implementation method in parent controller main.do Assumption is that the component id for details list is defined as ‘list’.







In list.do implement the interface method GET_CUSTOMERID  should be as shown below to get the customerid attribute .



In all of the above methods, only instance of Interface methods are obtained not the instance of concrete class(main.do as in Part I ) methods. If another application were to call details.do directly, with out changing the code in details.do, the calling application can set the attribute by implementing interface ZIF_DATA_EXCHANGE .
To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply