Basics of Model View Controller – What is MVC Framework?

A model view controller is known as  MVC

  • Invented by Smalltalk programmers.
  • Web development framework for scalable and extensible projects
  • Used for desktop GUI’s

Attributes :

  • An adapted architectural framework for all programming languages
  • design pattern inserts a controller class between view and model to remove model-view 
  • It makes new features convenient 

Components:

 Model:

  • A single or structure of objects 
  • It depends neither on the controller nor the view 

       A Model represents knowledge. It could be a single object or a Structure of objects. 

    There should be a one-to-one correspondence between the Model and its parts on one hand. On the other hand. the correspondence should be between the Model and the represented world as perceived by the owner of the Model. 

Functions of the Model are given as follows:

 • This component corresponds to all the data related logic that the user works with.

 • The Model can represent the data that is being transferred between the View and Controller components and also any other business-related logical data.

View:

  • A View is the visual representation of its Model.
  • It would usually highlight certain attributes of the model and suppress others. 
  • It acts as a presentation filter. 

   A View is attached to its model (or a part of the Model). and gets the data necessary for the presentation by asking questions to the model. It may also update the model by sending appropriate messages All these questions and messages have to be in the terminology of be Model 

The View will, therefore, have to know the semantics of the attributes of the model it represents. 

This Component is used for all the logic of the application 

Controller:

  • A Controller is a link between a user and the system. 
  • It provides inputs to the use by arranging for relevant views to present themselves in appropriate places on the screen. 
  • It provides means to the output by presenting the user with menus or other means of giving commands and data 

   The Controller receives the output. translates into the appropriate messages and passes these messages on to one or more of the Views. The Controller acts as an interface between the Model and the View to process all the business logic and incoming requests. It manipulates data using the Model component and interacts with the Views to render the final output 


Interaction Between the Components 

In addition, the application divides into three kinds of components. the MVC design defines the interaction between them The is how the interaction takes place 

  1. The Model stores data. which a retrieved according to the Commands from the Controller and displayed in the View 
  2. The View generates new output to the user based on all changes in the Model. 
  3. The Controller sends commands to the Model to update the Model’s state (for e.g. editing a document) It can also send commands to its view to change the view’s presentation of the Model.


The basic differences between Basic Web and MVC Web Architecture 


Basic Web architecture:

In a basic web architecture. the browser interacts with the web page and there is a web server sitting between. However, it gives a simplified view. also the web page might have a lot of codes to make decisions for us. the web page. finally sends the output back to the browser and it might even Interact with the database if it is enabled 

MVC Web Architecture :

In MVC, the browser communicates to the Controller, only the code involved in making the decision about the outcome or the actions. If we need to interact with the database or any other form of data the Controller interacts enters the Model and sends all of the code related to the data to the Model. Then the Model returns the data to the Controller When the Controller Is satisfied that it is ready to return the results back to the browser, it sends it to the View. The View is the presentation layer, that will decide what HTML/CSS/JavaScript has to get the response back. And the data is finally returned to the web page/browser.

Leave a Comment

Scroll to Top