Title: ModelViewController
1Model-View-Controller
2MVC
- One of the most common Design Patterns is
Model-View-Controller (MVC) - It separates business, navigation and
presentation logic - It is widely used in web-applications.
- Example of MVC frameworks for web-applications
Spring and Struts .
3MVC Components
- Model represents the application information. It
is the data and the computation. - View represents the view to render the model
(ex. Dynamic HTML, Swing, ...). The view can get
results from the controller - Controller It is responsible for processing and
responding to events.
4How to works
5A typical MVC task
1. The end user manipulates the view 2. The
user's actions are interpreted by the
view. 3. The view passes the interpreted
commands to the controller. 4. The controller
decides what should be done in a situation
like this. 5. According to its own intelligence
the controller makes the model act. 6. The
model acts independently. 7. After the model has
completed the tasks, the control returns to
the controller. It decides if the changes in
the model should cause changes in the view. 8.
If so, the controller gets all the information
needed from the model. 9. The controller passes
the information to the view. 10. The view
displays the information in its own way.
6Advantages of MVC
- One advantage is separation of concerns
- Consequently, code is cleaner and easier to
understand - Ease Maintenance Burden
- Changes to business logic are less likely to
break the presentation logic - Another big advantage is reusability
- The same model used for a servlet can equally
well be used for an application or an applet (or
by another process - Facilitate Multi-team development
- Developers can focus on business code and UI
Designers can focus on building without worrying
about the code