ABAP Objects Design Patterns – Model View Controller (MVC) Part 1

By | October 13, 2008 | ABAP Objects, OO Design Patterns | 87,364 | 6

Today we will discuss about the Design Pattern: Model-View-Controller, which is also very famous by its abbriviation MVC. By definition, MVC is to isolate the business logic from the User Interface which gives great degree of flexibility to change business logic independently to the user interface and vice versa.

Basics of MVC

In MVC, User Interface acts as the View; Business logic acts as the Model and the link which provides the link between the View and Model is known as the Controller. In real time business, MVC is used anywhere, where users have a choice to select his or her view. For example, Windows Media Player, Gmail or Yahoo mail and so on. All these type of application provides us the option to select the skin as per our choice.

Let’s take an example: We have to develop one Sales report for our corporate intranet. This report must have the option to display the sales data in the classical report format; different charts – pie, bar, line or both – report & chart and it must be based on the User’s choice. This type of requirements where we can easily separate the Business logic and the views are the best candidates for MVC.

Generally, Model sends the data to controller and controller will pass that data to Views and views will display the data as per their nature. In SAP, our business logic(model) will not send data unless and until View request for an data because ABAP is event driven language. Like user has to run some transaction to get the data, means application view has to initiate the process and ask for the data from the Model. In this requesting process, Controller will help the view to be apart from the model.

UML for MVC

UML diagram of the typical MVC application would be:

As we can see here, Model will send the data to the Controller and controller will pass that information to the View. Now, its a view’s responsibility to create a user specific view – Report, or Chart.

Advantages of using MVC:

Since both our business logic and view logic are different, we can easily change any of the logic without interrupting the other part.

In the next post, we will see how we can implement the MVC design pattern in ABAP usin the ABAP Objects.

SDN Wiki Model View Controller design Pattern

Like It? Share!!

Don't miss an Update

Get notified of the new post, right into your inbox

Naimesh Patel{274 articles}

I'm SAP ABAP Consultant for more than a decade. I like to experiment with ABAP especially OO. I have been SDN Top Contributor.
Follow :

Explore all of his 274 articles.

Load comments

6 Comments

  • Anonymous

    That was pretty good… Thanks for that. we would like to hear about MVC. But could not view the other links.

  • Thanks for pointing out the broken link. It has been corrected now.

    Regards,
    Naimesh Patel

  • th

    Thanks for the post.

    I'm studying about design patterns

    and I was wondered how can I apply them on abap

  • Anonymous

    How can i create a application??

  • Anonymous

    Can u provide other links for development?

  • Hello

    great Tutorial! I have a question regarding the UML-Modell. Isn’t wrong to use a dependency between the different classes? I think an association or a aggregation would apply better since you instantiating the model and view in the control class.

    regards Patrick

Comments on this Post are now closed. If you have something important to share, you can always contact me.

You seem to be new here. Subscribe to stay connected.