What is MVC(Model-View-Controller) Architecture

02nd, January 2018 By

Model–View–Controller (MVC) is an architecture that separates the representation of information from the user’s interaction with it.  The central idea behind MVC is code reusability and separation of concerns.

History:-

The model-view-controller pattern was originally formulated in the late 1970s by Trygve Reenskaug at Xerox PARC, as part of the Smalltalk system

Controller:-

The Controller serves as an intermediary between the Model, the View. controller mediates input, converting it to commands for the model or view.

For example,Controllers can be seen as managers taking care that all needed resources for completing a task are delegated to the correct workers.

Model:-

The Model represents your data structures. Typically your model classes will contain functions that help you retrieve, insert, and update information in your database.The model consists of application data and business rules.

For example,In the case of a social network, the Model layer would take care of tasks such as Saving the user data, saving friends associations, storing and retrieving user photos, finding new friends for suggestions, etc. While the model objects can be thought as “Friend”, “User”, “Comment”, or “Photo”.

View:-

The View is the information that is being presented to a user. A View will normally be a web page.A view can be any output representation of data.

For example, as the Model layer returns a set of data, the view would use it to render a HTML page containing it. Or a XML formatted result for others to consume.

Advantages Of MVC:-

1.Using mvc we can reuse the code.

2.Less coupling between the layers.

3.Separating of concerns.Means changes in one part as view not depend upon changes in controller.You can work independently in view part if another works in controller.The modular and separate design also allows developers and designers to work simultaneously.

4. MVC architecture turns an application into a maintainable, modular, rapidly developed package.

Model View Controller has been adapted as an architecture for World Wide Web applications.Various frameworks are created in mvc pattern .Like in php the framework cakephp,codeigniter,zend etc are  depends upon the mvc pattern.

Leave a Reply

Your email address will not be published. Required fields are marked *