Understanding Model View Controller (MVC)

MVC is a software design pattern, which splits an Application into three main aspects : Model, View, and Controller. Moreover, MVC pattern forces a separation of concerns within an application, for example, separating data access logic and business logic from the UI.

The benefits of using the Model-View-Control (MVC) pattern in our development projects is that we can completely decouple our business and presentation Application layers. The independence between the objects/layers in our project is that MVC provides somewhat easier maintenance  and code reuse is very easy.

As a general practice, we know, we want to keep the object dependencies in our projects to a minimum so changes are easy and we can reuse the code we’ve worked so hard on.

Learning the terms

  1. Models
    Models represent the knowledge. A model can be a single object or it can be some structure of objects.The model represents a set of classes, which describes the business logic and data. It also defines the business rules on how the data can be changed and manipulated.

  2. Views
    A view is a (visual) representation of its model. The View is responsible for transforming a model or models into UI. The model is responsible for providing all the required business logic and validation to the view. The view is only responsible for displaying the data which is received from the controller as the result.

  3. Controllers
    A controller is the link between a user and the system. It provides the user with an input by arranging for the relevant views to present themselves in appropriate places on the screen. The Controller is responsible for controlling the Application logic and acts as the coordinator between the View and the Model. The Controller receives input from the users via the View, processes the user’s data with the help of Model and passes the results back to the View.

    mvc

This sums up the basic understanding of the terms in MVC. I hope you like it and want to follow the series. Your valuable feedback, questions or comments about this article are always welcome.

Ebook Download
View all
Learn
View all