MVC
stands for Model-View-Controller architecture. It promotes loose coupling
between components by separating the functionality of displaying and
maintaining of the data. It is often used by applications that need the ability
to maintain multiple views like HTML, WML, Swing, XML based Web service etc.
Multiple views and controllers can interface with the same model. Even new
types of views and controllers can interface with a model without forcing a
change in the model design.
To
summarize the MVC does the following
- Separation of Model from View components makes it possible to implement several user interfaces that reuse the common core business logic.
- Duplication of low-level Model code is eliminated across multiple UI implementations.
- Decoupling of Model and View code results in an improved ability to write unit tests for the core business logic code.
- Modularity of components allows core logic developers and UI developers to work simultaneously without affecting the other.
A model
represents the core business logic and state. A model
commonly also maps to data the database and will also contain core business
logic.
- Manages the app data and state
- Not concerned with UI or presentation
- Often persists somewhere
- Same model should be reusable, unchanged in different interfaces
A view renders
the contents of a model. A view accesses the data from the model and adds display
logic to present
the data.
- Present the Model to the user in an appropriate interface
- Allows user to manipulate data
- Does not store any data.
- Easily reusable & configurable to display different data
A controller
acts as the glue between a model and a view. A controller translates
interactions with the view into actions to be performed by the model. User
interactions in a Web application appear as GET and POST HTTP requests. The actions performed by a model
include activating business processes or changing the state of the model. Based
on the user interactions and the outcome of the model actions, the controller
responds by selecting an appropriate view.
- Intermediary between Model & View
- Updates the view when the model changes
- Updates the model when the user manipulates the view
MVC pattern decouples how data is manipulated from how data
is displayed or stored. MVC is a way of developing apps by keeping the data
(model) used in the program, and the visual (view) component separate from one
another, each interacting only with a controller containing the logic. The view
and the model interact only with the controller NEVER with
each other.
MVC |
Nice Article . Easy and Clear Explanation . Thumbs up :)
ReplyDelete