
1
Design Patterns:
Model-View Separation
Motivation:
•Suppose you have a system that needs to
run on a variety of devices
–Maybe a cell phone and a PDA
–Maybe Windows and with a command line
–. . .
•Think about the current programming
assignment
Motivation:
•Suppose we support both the command line
and the GUI interfaces.
Model-View Separation Pattern
•Model: The domain layer of objects.
(objects that contain data and operations).
•View: The presentation layer of objects
(windows, applets, reports).
Model-View Context
•Context/Problem
It is desirable to de-couple domain (model) objects from
windows (views), to support increased reuse of domain
objects, and minimize the impact of changes in the
interface upon domain objects.
Model-View Context
•Context/Problem
It is desirable to de-couple domain (model) objects from
windows (views), to support increased reuse of domain
objects, and minimize the impact of changes in the
interface upon domain objects.
•Solution
Define the domain (model) classes so that they do not have
direct coupling or visibility to the window (view) classes,
and so that application data and functionality is maintained
in domain classes, not window classes.