Preface – This post is part of the SAP ABAP Web Dynpro series.
Table of Contents
Web Dynpro follows MVC architecture. This model, view and controller design is very helpful while designing any web application as it properly segregates the business logic from (HTML-based) views. The three parts work in such a manner that it gives the user a very easy way of accessing the application.
As mentioned in the previous articles models are objects that contains business logic statements to read or write data into the database. This model can be developed in various forms depending on the requirements as like Function Modules, BAPI`s, Classes, etc. Model, when created as a class (Model class), is nothing but a class which forms certain data in it which one will want to show in Web Dynpro Screen.
In simple words, the view is the screen that is displayed in the browser for the user. This is the place where the user actually interacts with the application. User will provide the input through view in order to fetch the required result. It is used to ensure the appropriate representation of data in a web browser.
Controller works like an interface between the model (which hold the data) and view (which displays the data). That means this is used to control communication between Model and View where it takes input from the users and gets the desired data from the model and displays the data in the browser.
How MVC Architecture works
Basically, MVC segregates the web application into three different modules, for better understanding let us take an example. Suppose you went to a restaurant to have dinner with your friends, after a couple of minutes you decided what to eat then a waiter came and you gave the order, after noting down he went and gave order details to the chef. Now chef will gather ingredients to prepare your order. After completion of your order, he will notify the waiter to deliver the food to your table. So in a way you are giving your Model name to your View and your view is pulling the data from a model and showing with the help of the controller. This is how any MVC Architecture will work.
Advantages of MVC Architecture
- It is easy to identify where the business logic and view design is. The model will contain only the business Logic, View will contain only the UI design, Controller will contain the code to get the value from UI and send it to Model and vice-versa.
- Due to the segregated design pattern, it is easy to enhance the design and business logic as per the requirement.
- Use of graphical tools in view part reduces the coding effort.
- Use of data binding and context mapping concepts in view part passes the data automatically from source to destination without handling the data.
- The goal of MVC is, by segregating models and views, to reduce the complexity in architectural design and to increase flexibility and maintainability of code.