Sunday, June 11, 2017

Architectural Pattern: MVC

The MVC (Model-View-Controller)  architecture has its roots in Smalltalk programming language, where it was originally applied to map the traditional input, processing, and output tasks to the graphical user interaction model. Following diagram shows the MVC architecture.






 The MVC consist of three parts:
·  Model: Model is the core of the application which maintains the state and data that the application represents. It knows nothing about the views representing this model.

·  View: The view renders the contents of a model. It specifies how the model should be presented. It is the view's responsibility to maintain consistency in its presentation when the model changes.  There may be several views representing the same model.

·  Controller: The controller translates user interactions with the view into actions to be performed by the model. In a stand-alone GUI client, user interactions could be button clicks or menu selections, whereas in a Web application, they appear as GET and POST HTTP requests. Based on the user interactions and the outcome of the model actions, the controller responds by selecting an appropriate view.

Lets discuss how this architecture implemets in popular java web frameworks.