COMP 310
Spring 2018

Lab03:  MVC implementation

Home  Info  Canvas   Java Resources  Eclipse Resources  Piazza

Model-View-Controller Design Pattern

The MVC pattern enables us to decouple the view (the user interface portion) from the model (the back-end computations) in a large system. This decoupling will allow

The model and the view do not know anything about each other.   Their communications consist of calling methods on interfaces to the rest of the system.   The model and view must provide public methods (services) that can be used to communicate to them.   Note that these services need not be standardized or abstracted, while the services they desire from the rest of the system must be abstracted into interfaces.   (Why?)

The model and the view are connected by adapters that translate the interfaces into the provided services.

The controller is the only part of the system that knows the concrete classes being used by the view and by the model.  The controller's job is to:

If the model or view is changed, then the controller will usually need to be changed as well, but any effect should be contained to only the controller.

The controller should be fairly simple and should never contain any "business logic".   If it becomes overly complicated, this is a sign that it is doing work that belongs in either the view or more likely, the model.   Is the model missing a module or a layer?

Criteria for determining if methods belong on the same or different adapter interfaces: 

For instance, the methods used to start a new game should be separate from those used to control the game while it is running.

MVC Design for BallWorld  (Illustrative purposes only--Individual student's designs are not required to look exactly like this!):

(Click for full-size image)
Ballworld MVC design


© 2018 by Stephen Wong