Using Patterns to Document Frameworks - PowerPoint PPT Presentation

1 / 24
About This Presentation
Title:

Using Patterns to Document Frameworks

Description:

Make a class hierarchy that models the different kinds of states that client could be in. ... Make a Drawing Decorator class (SelectionDrawing) to hide and ... – PowerPoint PPT presentation

Number of Views:76
Avg rating:3.0/5.0
Slides: 25
Provided by: RalphJ4
Category:

less

Transcript and Presenter's Notes

Title: Using Patterns to Document Frameworks


1
Using Patterns to Document Frameworks
  • Frameworks contain patterns
  • Patterns are design decisions

2
Design
  • Design is a set of choices.
  • Choices made one at a time.
  • Ideally, all choices are correct.
  • Each choice based on current information.

3
Design Documentation
  • Need to learn a bit at a time.
  • Need to know why a decision was made.
  • Know when to change it.
  • Know how to adapt to it.

4
Using Patterns for Documentation
  • Patterns can describe how to use a system.
  • Documenting Frameworks Using Patterns
  • Patterns can describe the design of a system. A
    sequence of patterns, one for each design
    decision.
  • Patterns Generate Architectures

5
HotDraw A Framework for Graphics Editors
6
Overview of Derivation of HotDraw
  • Model-View-Controller user interface
  • Composite Design Patterns
  • State Design Patterns
  • Editor (to operate on drawing)
  • Observer Design Patterns
  • Collect Damage user interface
  • Update at User Speed user interface
  • Editor (to operate on figure)
  • Decorator Design Patterns

7
Model-View-Controller
Drawing
DrawingView
DrawingController
8
Composite
Drawing contains many figures. Make Drawing be a
composite figure.
Figure
Display
Drawing
Drawing
EllipseFigure
9
State
  • Allow an object to alter its behavior when its
    internal state changes.
  • The object will appear to change classes.
  • Make a class hierarchy that models the different
    kinds of states that client could be in.

10
  • Client points to its "current state".
  • Client delegates all state-dependent behavior to
    current state.
  • Tools are the "current state" of the
    DrawingController it delegates operations to the
    current state.

11
Figure
Display
Drawing
Drawing
current tool
Tool
DrawingController
12
Editor
  • Who creates the tools that the DrawingController
    will use as states?
  • Different drawings will need different Tools.
  • Make Drawing responsible for knowing Tools that
    can operate on it.

13
Figure
Display
Drawing
Drawing
Default tools
current tool
DrawingController
Tool
14
What is a Pattern?
  • Is Editor a pattern, or a combination of
    patterns?
  • Con same as using Factory Method to produce an
    Adapter.
  • Pro Editor has a unique intent to provide a
    common interface to a heterogenous collection of
    objects.

15
What is a Pattern?
  • Are two patterns with the same solution the same
    pattern?
  • Are combinations of patterns also patterns?

16
Observer
  • Each Figure knows its dependents, and notifies
    them when it changes state.
  • Dependents of a figure include its Drawing, so
    the Drawing can redisplay itself if a figure
    changes.

17
Collect Damage
  • How do you display as little as possible?
  • Have the graphics system keep track of the part
    of the image that has changed, a damaged
    region. Every time a part of the image changes,
    add its area to the damaged region. Redisplay
    the changed region when possible.

18
Figure
Display
Drawing
dependent model
Drawing
DrawingView
Default tools
Damaged region
current tool
DrawingController
Tool
19
Update at User Speed
  • Update too fast, and all the time is spent doing
    graphics.
  • Update too slow, and animation is jerky.
  • Update the drawing at the same speed that the
    user makes gestures. Redisplay the drawing once
    for each user event.

20
Editor
  • How to operate on Figures?
  • Ask Figures for their handles and then operate on
    the handles.

21
Figure
Display
Handles
Drawing
dependent
Drawing
DrawingView
model
Default tools
Damaged region
current tool
Tool
DrawingController
22
Decorator
  • Should handles go in the Drawing? No - 2 views of
    a drawing.
  • In the View? This makes views complex.
  • Make a Drawing Decorator class (SelectionDrawing)
    to hide and show sets of handles.

23
Figure
Display
Handles
Drawing
Drawing
Handles
Default tools
dependent
DrawingView
SelectionD.
model
Damaged region
current tool
Tool
DrawingController
24
Summary of Derivation of HotDraw
  • How I wish I had done it.
  • Rational design.
  • Describes "why" of a feature, not just how it is
    implemented.
  • Lots of different kinds of patterns are necessary.
Write a Comment
User Comments (0)
About PowerShow.com