Model-View Separation Pattern in Software Design, Study notes of Computer Science

The model-view separation pattern, a design approach that separates the domain logic from the user interface. The motivation behind this pattern is to increase reusability and minimize the impact of interface changes on domain objects. The pattern involves defining domain classes that do not have direct coupling or visibility to window classes, and allowing new views to be easily connected to an existing domain layer. The document also introduces the concept of indirect visibility through the publish-subscribe pattern, which allows domain objects to communicate with windows without direct knowledge of each other.

Typology: Study notes

Pre 2010

Uploaded on 08/19/2009

koofers-user-f3j
koofers-user-f3j 🇺🇸

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
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.
pf3

Partial preview of the text

Download Model-View Separation Pattern in Software Design and more Study notes Computer Science in PDF only on Docsity!

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.

Model-View

Window Configuration display( ) addEntry( ) query( ) Model View

Model-View Separation

Motivation

Motivation

  • Focus more on the domain processes rather than

on computer interfaces.

  • Allow separate development of the model and user

interface layers.

  • Minimize the impact of changes in the interface

upon the domain layer.

  • Allow new views to be easily connected to an

existing domain layer.

Problem

Window Configuration display( ) addEntry( ) query( ) Model View displayMessage ( )

Model-View Separation Pattern

Configuration addEntry( ) query( ) Model View query( ) New Window display( )

Model-View Separation Pattern

• Problem: Domain objects need to

communicate with windows to cause a real-

time ongoing display update as the state of

information in the domain object changes.

- Monitoring applications

- Simulation applications.

Model-View Separation Pattern

with Indirect Visibility

  • Named Publish-Subscribe Pattern
  • Context/Problem: A change in state (an event) occurs within a Publisher of the event and other objects are dependant on or interested in this event (Subscribers to the event). However the Publisher should not have direct knowledge of its subscribers.