Tuesday 8 September 2015

Introduction to MVC

In programming, there is a term called “design patterns” that allow the developers to share their problems and solutions that benefit everyone. A design pattern is capable to identify the problem’s definition and context, a possible solution, and the solution’s consequences.
Christopher Alexander, the initiator of the term “design pattern” in software engineering has stated that each pattern is divided into 3 part rule which expresses a relation between a certain context, a problem, and a solution. Hence, Design patterns provide reusable solution to recurring problems when developing software within a particular context.
Here, the Java Enterprise Edition uses the MVC (Model – View – Controller) as a design pattern used in most of the enterprise applications.
The MVC architecture divides the web – based application into 3 parts: the Model, the View and the Controller.
The pattern used separates the modeling of the domain, the presentation, and the actions based on user input into three separate classes.
Model : defines the lowest level of the pattern maintains data, data representation and business logic.
View : displays all or a portion of the data to the user and user input.
Controller : controls the interactions between the model and view using software code and to dispatch requests and control flow.
Most Web-tier application frameworks use some variation of the MVC design pattern, The MVC (architectural) design pattern provides a host of design benefits.

Model:

The Model's responsibilities
  • Provide access to the state of the system
  • Provide access to the system's functionality
  • Can notify the view(s) that its state has changed

View:

The view's responsibilities
  • Display the state of the model to the user
  • At some point, the model (the observable) must registers the views (the observers) so the model can notify the observers that its state has changed.

Controller:

The controller's responsibilities
  • Accept user input
    • Button clicks, key presses, mouse movements, slider bar changes
  • Send messages to the model, which may in turn notify it observers
  • Send appropriate messages to the view
 

No comments:

Post a Comment