Lecture 8

Topic 8: Model-View-Controller: The Basic Architecture

- further discussion of DotPanel and its role in DrawVersion6.java
- coverage of the roles of the model, view, and controller aspects of an application

Learning Objective: can you explain why a modification to the model (in this case, an object of type SimpleThreeDotModel) has the result that a portion of the screen gets redrawn by the window manager?

Class discussion of the URL-based labtests from the week 3 labtests

*assumption: all students have downloaded and successfully invoked the L7L8 example applications from the "Course Materials" section of this site.


The Model-View-Controller (MVC) Paradigm

The MVC paradigm isolates "domain logic" (the application logic for the user) from the user interface (input and presentation),
permiting independent development, testing and maintenance of each (separation of concerns).

The model
- manages the behavior and data of the application domain
- responds to requests for information about its state (usually from the view),
- responds to instructions to change state (usually from the controller).
- notifies observers (usually views) when the information changes, so that they can react.
- is both the data and the business/domain logic needed to manipulate the data in the application
- In sum, the model holds all of the data, state, and application logic. The model is oblivious to the view and the controller, although it provides an interface to manipulate and retrieve its state and it can send notifications of state changes to observers.

The view
- Renders the model into a form suitable for interaction, typically a user interface (which itself is a set of interactive elements (widgets), which are hierarchically composed)
- Multiple views can exist for a single model for different purposes.
- In sum, the view provides a presentation of the model. The view gets the state and the data it needs for its display directly from the model. The view is an observer of the model, so that when the model changes, the view knows that it is time to update itself.

The controller
- receives input and initiates a response by making calls on the model.
- accepts input from the user and instructs the model to perform actions based on that input.
- In sum, the controller takes the user input and figures out what it means to the model