What is MVC Framework?

How to Represent it Using UML Sequence Diagram?

MVC (known as Model-View-Controller) is a pattern in software design that is commonly used to implement user interfaces, data, and control logic. It emphasizes the separation between the business logic and presentation of the software. This “separation of concerns” provides better division of labor and better maintenance.

The Three Parts of MVC

The three parts of the can be described as follows:

  • Model: Manage data and business logic. The model is responsible for managing the data of the application. It receives user input from the controller.
  • View: Handles layout and display. The view renders presentation of the model in a particular format.
  • Controller: routes commands to model and view parts. The controller responds to user input and performs interaction with the data model object. The controller receives the input, optionally validates the input, and then passes the input to the model.

For example, our shopping list can have input forms and buttons that allow us to add or delete items. These operations need to update the model, so the input is sent to the controller, then the controller manipulates the model as needed, and then the controller sends the updated data to the view.
However, you may just want to update the view to display the data in a different format, for example, changing the order of items to alphabetical order, or changing the lowest price to the highest price. In this case, the controller can deal with this problem directly without updating the model.

Application of MVC in Software Development

The MVC framework has been widely used by many software developers as well as other software frameworks and libraries. Traditionally used for desktop graphical user interfaces (GUIs), this pattern has become a popular one for designing Web applications.

Popular programming languages have MVC frameworks to facilitate the implementation of patterns, such as JavaScript, Python, Ruby, PHP, Java, and C# all have MVC frameworks that can be used directly for web application development.

How to Represent it Using UML Sequence Diagram?

In the following general MVC sequence diagram, it shows that the view object is responsible for the user’s input and output, that is, the dialog box is a good example of the view. The controller object implements the logic that allows transactions to be executed on the model. Model objects encapsulate fine-grained business logic and data.

MVC Sequence Diagram Example: Hotel Reservation Fragment

This sequence diagram example shows how hotel reservations can be made. This sequence diagram captures the behavior of a single hotel reservation scenario by showing a number of example objects and the messages that are passed between these objects as shown in the diagram below:

Related MVC Framework

Some other design patterns are based on MVC, such as MVVM (Model View Model), MVP (Model view Demonstrator), and MVW (Model view)

IT professional