Introduction to POAD - Lane Department of Computer Science and

Download Report

Transcript Introduction to POAD - Lane Department of Computer Science and

Introduction to Pattern Oriented
Analysis and Design (POAD)
Instructor: Dr. Hany H. Ammar
Dept. of Computer Science and
Electrical Engineering, WVU
Outline



Review of Design Patterns
– The Lifecycle of a Pattern
– Examples of Design Patterns
 The Command Pattern
 The Observer Pattern
 The Strategy Pattern
Pattern Oriented Development
– The Analysis phase
– The Design phase
– The design refinement phase
The Feedback Control Example
The Lifecycle of Patterns
(From the Reference “Pattern-Oriented Analysis and Design”,
Sherif M Yacoub and Hany H. Ammar Addison-Wesley Inc., 2004)
Legend
Activit
y
Produc
t
Real World
Projects
Discover
Patterns
Incident
Occurrence of a
Pattern
Pattern Mining
Document
Modification
Feedback
Phase I:
MINING
Author World
Document
Author
Version
Pattern Polishing
Reusable
Version
Pattern Reuse
Analyze/Rule of
Three
Preliminary
Documentati
on
Phase II:
POLISHING
Pattern
Community World
Phase III:
REUSE
Pattern User
World
Review of Design Patterns

Examples of Design Patterns (From the Design
Patterns CD by Gamma et al, Addison-Wesley Inc., 1998 )
The Command Pattern: Encapsulate a request as
an
object
Review of Design Patterns
The Command Pattern
From the Design Patterns CD by Gamma et al, Addison-Wesley Inc., 1998
Review of Design Patterns
Examples of Design Patterns
The Observer Pattern: when one object changes state,
all its dependents are notified and updated automatically
Model View
Controller
example
Review of Design Patterns
Examples of Design Patterns
The Observer Pattern class diagram
From the Design Patterns CD by Gamma et al,
Addison-Wesley Inc., 1998
Review of Design Patterns
Examples of Design Patterns
The Strategy Pattern: lets the algorithm vary
independently from clients that use it
Pattern Oriented Development
Design Patterns are used in an ad-hoc
strategy for design refinement
 They are also used to address a set of design
problems without any guidance of how
these patterns can be glued or interface
together
 Is there a way to use design patterns as
building blocks or as components in the
design of systems ?

Pattern Oriented Development
 Pattern
Oriented Analysis and Design
(POAD)
The
process aspects of POAD explains
the phases and steps to develop an
application design using patterns
the POAD process has three phases:
–
–
–
Analysis
Design
Design Refinement
Pattern Oriented Development
Analysis
a logical model is developed and
patterns are selected
Design
where patterns are glued together
to produce a detailed pattern-level
diagram
Design
Refinement
An initial class diagram,
and a more dense and profound class diagram,
and sequence diagrams are developed
Application
Requirements
The POAD process
a) overall phases, b) analysis, c) design, and d) design refinement
(a) Overall POAD
Pattern
Library
Requirem
ent
Analysis
Acquaintan
ce
Required
Conceptual
Components
Retrieval
Selection
Analysis
Candidate
Patterns
Design
Selected
Patterns
(b) Analysis
Design
Refinement
Selected
Patterns
(d) Design Refinement
Detailed PatternLevel Diagrams
Concretizatio
n
Instantiating Pattern
Internals
Domain Specific Detailed
Pattern-Level Diagrams
Specializatio
n
Develop Class
Diagrams
Constructing
Pattern-Level
models
Define
Pattern
Relationships
Pattern-Level
Diagrams
Construct
Pattern-Level
Diagrams
Constructing models for
Pattern-Level with
Interfaces
Pattern-Level with
Interfaces
Diagrams
Constructing models for
Detailed Pattern-Level
Initial UML class diagram
Reductio
n
Design
Optimization
Optimized class diagram
Merging &
Grouping
Create
Pattern
Instances
Detailed PatternLevel Diagrams
(c) Design
Declare
Pattern
Interfaces
Identify
Relationships
between Pattern
Interfaces
POAD Analysis Phase




Develop use case diagrams to identify the
problems to be solved and the possible breakdown
of the application as a set of logical components.
Acquaintance with relevant pattern databases to
get the analyst familiar with existing solutions.
Retrieval of patterns from the domain specific
databases to select a set of candidate patterns in an
automated fashion.
Selection of patterns from a set of candidate
patterns for possible inclusion in the design
process.
Construct Pattern-Level Models
Create an instance for each selected pattern
by describing the patterns and their
constituents in an application specific
context
 Define how these instances are related to
each other
 The semantic of a dependency relationship
used between patterns has a "uses" meaning

The Feedback Control Example
From Pattern-Oriented Analysis and Design,
Sherif M Yacoub and Hany H. Ammar Addison-Wesley Inc., 2004

Block diagram for a feedback control
system
Error
Reference
Input
(Actuating)
Signal
+
Feed forward
Elements
Plant.
+
Feedback
Data
Controlled
Output
Feedback
Elements
Measurement
The Feedback Control Example

POAD Analysis Phase (Pattern Selection)
–
–
–
–
The feedforward component implements some sort of a
control strategy (instance of Strategy pattern)
The feedback component receives measurements and applies
a feedback control strategy
In the error calculation component, the feedback controller
notifies the error calculation unit with the feedback data
(instances of the Observer pattern)
Data of different types need to be exchanged between the
framework components (Measurement,
Feedback Data, input data , and error data )
The Feedback Control Example
Pattern-Level diagram for feedback control system
This is an architectural pattern based on the data flow architectural style
Plant
<<Observer>>
FeedbackObserver
<<Strategy>>
FeedforwardStrategy
Apply forward control strategy
<<Observer>>
ErrorObserver
Apply feedback control strategy
<<Strategy>>
FeedbackStrategy
Calculate Error
Manipluate Data
Manipluate Data
<<Blackboard>>
Blackboard
Manipulate Data
The Feedback Control Example
Pattern-Level with Interfaces
Notify
<<Strategy>>
FeedforwardStrategy
(from POAD1-Feedback)
<<Observer>>
FeedbackObserver
(from POAD1-Feedback)
Context
Update
<<Observer>>
ErrorObserver
(from POAD1-Feedback)
Update
setData
<<Strategy>>
FeedbackStrategy
(from POAD1-Feedback)
Notify
Context
<<Blackboard>>
Blackboard
(from POAD1-Feedback)
getData
The Feedback Control Example
Detailed Pattern-Level diagram
<<Strategy>>
FeedforwardStrategy
(from POAD1-Feedback)
<<Observer>>
FeedbackObserver
(from POAD1-Feedback)
Subject
Context
Strategy
ContextInterface()
AlgorithmInterface()
Observer
Update()
n
Attach()
Detach()
Notify()
Notify
Context
ConcreteStrate
gyA
ConcreteStrate
gyB
AlgorithmInterface()
AlgorithmInterface()
ConcreteOb
server
observerState
Update()
<<Observer>>
ErrorObserver
(from POAD1-Feedback)
ConcreteS
ubject
subjectState
getState()
Update
<<Strategy>>
FeedbackStrateg y
(from POAD1-Feedback)
Subject
Observer
Update()
n
Attach()
Detach()
Notify()
Update
Notify
ConcreteObserver
observerState
ConcreteSubject
subjectState
Update()
getState()
Context
Context
Strategy
ContextInterface()
AlgorithmInterface()
ConcreteStrategyA
AlgorithmInterface()
setData
getData
<<Blackboard>>
Blackboard
(from POAD1-Feedback)
Blackboard
DataHolder
setData()
getData()
n
ConcreteDataHolderA
ConcreteDataHolderB
ConcreteStrategyB
AlgorithmInterface()
The Feedback Control Example
Instantiating the ErrorObserver pattern
<<Observer>>
ErrorObserver
(from POAD1-Feedback)
AbstractSubject
AbstractObserver
Update()
n
Attach()
Detach()
Notify()
Notify
Update
ErrorObserver
observerState
Update()
FeedbackSu
bject
subjectState
GetState()
The Feedback Control Example
Instantiating the FeedforwardStrategy pattern
<<Strategy>>
FeedforwardStrategy
(from POAD1-Feedback)
Controll er
AbstractControll er
ContextInterface()
Algori thmInterface()
Controller
ConcreteStrategyA
ConcreteStrategyB
Algori thmInterface()
Algori thmInterface()
The Feedback Control Example
Instantiating the Blackboard pattern
<<Blackboard>>
Blackboard
(from POAD1-Feedback)
Blackboard
setData
DataHolder
setData()
getData()
getData
ErrorData
n
MeasuredData
FeedbackData
The Feedback Control Example
The initial class diagram
AbstractSubject
AbstractObserver
Controll er
AbstractControll er
ContextInterface()
Algori thmInterface()
Update()
Attach()
Detach()
Notify()
n
FeedbackObserver
MeasurementSubject
observerState
ConcreteStrategyA
ConcreteStrategyB
Algori thmInterface()
Algori thmInterface()
subjectState
Update()
GetState()
AbstractSubject
AbstractObserver
Update()
ErrorObserver
n
Attach()
Detach()
Notify()
subjectState
Update()
GetState()
Algori thmInterface()
ContextInterface()
FeedbackSubj ect
observerState
FBAbstractControl ler
Feedback
FBConcreteStrategyA
Algori thmInterface()
Blackboard
DataHol der
setData()
getData()
ErrorData
n
MeasuredData
FeedbackData
FBConcreteStrategyB
Algori thmInterface()
The Feedback Control Example
The refined class diagram ready for code generation
Control l er
AbstractControl l er
ContextInterface()
Al gori thmInterface()
ConcreteStrategyA
ConcreteStrategyB
Al gori thm Interface()
Al gori thm Interface()
FBConcreteStrategyA
FBConcreteStrategyB
Al gori thm Interface()
Al gori thm Interface()
AbstractSubject
AbstractObserver
Update()
Attach()
Detach()
Noti fy()
n
FeedbackSubjectObserver
ErrorObserver
M easurem entSubj ect
observerState
subj ectState
Update()
GetState()
Bl ackboard
DataHol der
setData()
getData()
ErrorData
n
M easuredData
FeedbackData
The Feedback Control Example

Object Collaboration Diagram
F_controller :
AbstractController
1: Apply (DataHolder*)
15: Control (DataHolder*)
13: Analyze()
Strategy1 :
ControlStrategyA
FB_Strategy :
FBControlStrategyA
12: GetInput()
9: Notify()
2: Notify ( )
5: MeasurePlant ( )
7: FBApply ()
3: Update ( )
10: Update()
Error :
ErrorObserver
11: Getstate()
14: Update ()
Feedback :
FeedbackSubjectObserver
8: Update ()
TheBlackboard:
Blackboard
Measurement :
MeasurementSubject
4: GetState ( )
6: Update ()