Upload
others
View
21
Download
0
Embed Size (px)
Citation preview
Introduction to Pattern Oriented Analysis and Design (POAD)
Instructor: Dr. Hany H. AmmarDept. 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
Real World Projects
Pattern Mining
Discover Patterns
Incident Occurrence of a Pattern
Preliminary Documentati
on
Document Analyze/Rule of Three
Author Version
Document
Pattern Polishing
Reusable Version
Pattern Reuse
Feedback
Modification
Phase I: MINING
Author World
Phase II: POLISHING
Pattern Community World
Phase III: REUSE
Pattern User World
Legend
ActivityProduct
(From the Reference “Pattern-Oriented Analysis and Design”, Sherif M Yacoub and Hany H. Ammar Addison-Wesley Inc., 2004)
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 PatternsExamples of Design PatternsThe Observer Pattern: when one object changes state, all its dependents are notified and updated automatically
Model ViewControllerexample
Review of Design Patterns
Examples of Design PatternsThe Observer Pattern class diagram
From the Design Patterns CD by Gamma et al, Addison-Wesley Inc., 1998
Review of Design PatternsExamples 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
Design
Design Refinement
a logical model is developed andpatterns are selected
where patterns are glued together to produce a detailed pattern-level
diagram
An initial class diagram,and a more dense and profound class diagram,
and sequence diagrams are developed
Acquaintance Pattern
Library
Candidate Patterns
Selection
Selected Patterns
Application Requirements
Requirement
Analysis
Required Conceptual
Components
Retrieval
Pattern-Level Diagrams
Constructing Pattern-Level
models
Create Pattern
Instances
Define Pattern
Relationships
Construct Pattern-Level
Diagrams
Constructing models for Pattern-Level with
Interfaces
Pattern-Level with Interfaces Diagrams
Declare Pattern
Interfaces
Identify Relationships
between Pattern Interfaces
Constructing models for Detailed Pattern-Level
Detailed Pattern-Level Diagrams
Selected Patterns
(c) Design
Instantiating Pattern Internals
Domain Specific Detailed Pattern-Level Diagrams
Specialization
Concretization
Develop Class Diagrams
Initial UML class diagram
Design Optimization
Reduction
Merging & Grouping
Optimized class diagram
Detailed Pattern-Level Diagrams(d) Design Refinement
Analysis
Design
Design Refinement
(b) Analysis
(a) Overall POAD
The POAD processa) overall phases, b) analysis, c) design, and d) design refinement
POAD Analysis Phase
Develop use case diagrams to identify theproblems to be solved and the possible breakdownof the application as a set of logical components.
Acquaintance with relevant pattern databases toget the analyst familiar with existing solutions.
Retrieval of patterns from the domain specificdatabases to select a set of candidate patterns in anautomated fashion.
Selection of patterns from a set of candidatepatterns for possible inclusion in the designprocess.
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
Block diagram for a feedback control system
Reference Input
Measurement
Feedback Data
Error (Actuating)
Signal Feed forward Elements
Feedback Elements
Plant.+
+
Controlled Output
From Pattern-Oriented Analysis and Design, Sherif M Yacoub and Hany H. Ammar Addison-Wesley Inc., 2004
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
FeedforwardStrategy<<Strategy>>
FeedbackObserver<<Observer>>
FeedbackStrategy<<Strategy>>
ErrorObserver<<Observer>>
Blackboard<<Blackboard>>
Apply forward control strategy
Manipluate Data
Plant
Apply feedback control strategy
Manipulate Data
Calculate Error
Manipluate Data
Pattern-Level diagram for feedback control systemThis is an architectural pattern based on the data flow architectural style
The Feedback Control Example
FeedforwardStrategy(from POAD1-Feedback)
<<Strategy>> FeedbackObserver<<Observer>>
(from POAD1-Feedback)
FeedbackStrategy<<Strategy>>
(from POAD1-Feedback)ErrorObserver<<Observer>>
(from POAD1-Feedback)
Blackboard<<Blackboard>>
(from POAD1-Feedback)
Context
Update Notify Context
Update
Notify
setData getData
Pattern-Level with Interfaces
The Feedback Control Example
F e e d f o r w a r d S t r a t e g y( f r o m P O A D 1 - F e e d b a c k )
< < S t r a t e g y> >F e e d b a c kO b s e r ve r
( f r o m P O A D 1 - F e e d b a c k)
< < O b s e r ve r > >
F e e d b a c kS t r a t e g y( f r o m P O A D 1 - F e e d b a c k )
< < S t r a t e g y> >
E r r o rO b s e rv er( f r o m P O A D 1 - F e e d b a c k)
< < O b s e r ve r > >
B l a c kb o a r d( f r o m P O A D 1 - F e e d b a c k )
< < B l a c kb o a r d > >
C o n te x t
U p d a t e N o t i f y C o n t e x t
U p d a t e
N o t i f y
s e t D a t a
g e t D a t a
C o n c r e t e O bs e r v e r
o b s e r v e r S t a t e
U p d a t e ( )
C o n c r e t e Su b je c t
s u b je c t S t a t e
g e t S t a t e ( )
S ub je c t
A t t a c h ( )D e t a c h ( )N o t if y ( )
O b s e r v e rU p d a t e ( ) nn
S u b je c t
A t t a c h ( )D e t a c h ( )N o t if y ( )
O b se rv erU p d a t e ( )
C o n c r e t e O b s e r v e ro b s e r v e r S t a t e
U p d a t e ( )
C o n c r e t e S u b je c ts u b je c t S t a t e
g e t S t a t e ( )
nn
C o n c r e t e S t r a t eg y A
A lg o r it h m I n t e r f a c e ( )
C o n c r e t e S t r a t eg y B
A lg o r ith m I n te r f a c e ( )
C on t e xt
C o n t e x t I n t e r f a c e ( )
S t r a t e g y
A lg o r it h m I n t e r f a c e ( )
C o n t e x t
C o n t e x t I n t e r f a c e ( )
S t r a t e g y
A lg o r it h m I n t e r f a c e ( )
C on cr e t e S t ra t eg yB
A lg o r it h m I n t e r f a c e ( )
C on c r et e S t ra t eg y A
A lg o r ith m I n te r f a c e ( )
C o n c r e t e D a t a H o ld e r A C o n c r e t e D a t a H o ld e r B
B la c k b o a r d
s e t D a t a ( )g e t D a t a ( )
D at a Ho ld e r
nn
Detailed Pattern-Level diagram
The Feedback Control Example
E rrorObserver(fro m P OA D1-Feedback )
<<Observer>>
E rro rO b se rve ro b se rve rS ta te
Up d a te ()
Fe ed b a ckS ub je ct
su b je ctS ta te
G e tS ta te ()
A b stra ctS u b je ct
A tta ch ()De ta ch ()No ti fy()
A b stra ctO b se rve r
Up d a te () nn
Up date Notify
Instantiating the ErrorObserver pattern
The Feedback Control Example
F e ed fo rw a rdS t ra tegy(fro m P O A D 1-F eedbac k )
<< S t ra t e g y> >
C o n c re te S tra te g y A
A l g o ri th m In te rfa c e ()
C o n c re te S tra te g y B
A l g o ri th m In t erfa c e()
A b s tra c tC o n t ro l l e r
A l g o ri th mIn te rfa c e ()
C o n tro l l e r
C o nte xt In te rf a ce ()
C o n t ro lle r
Instantiating the FeedforwardStrategy pattern
The Feedback Control Example
Blackboard(from POAD1-Feedback)
<<Blackboard>>
Blackboa rd
setData ()ge tData()
Da ta Hold er
getData
setData
nn
ErrorData MeasuredData FeedbackData
Instantiating the Blackboard pattern
The Feedback Control Example
D a ta H o l d e r
E rro rD a t a M e a su re d D a ta F e e d b a c kD a ta
A b s t ra c tO b s e rv e r
U p d a t e ( )
A b st ra c tS u b j e c t
A t ta c h ()D e t a c h ()N o t i f y ()
nn
A b st ra ct C on t ro ll e r
A l g o ri t h m In te rfa c e ()
C o n c re te S t ra t e g y B
A l g o ri t h m In t e rfa c e ()
C o n c re t eS t ra te g yA
A l g o ri t h m In te rfa c e ()
F B A b s t ra c t C o n t ro l l e r
A l g o ri t h mIn te rf a c e ()
F B C o n c re t e S t ra te g y B
A l g o ri t h m In te rfa c e ()
F B C o n c re te S tr a t e g y A
A lg o ri t h m In te rfa ce ()
F e e d b a c k
C o n t e x t I n t e rf ac e ()
F e e d b a c kS u b j e c tsu b j e c tS ta te
G e t S t a te ()
E rr o r O b se rv e ro b se rv e rS ta te
U p d a te ()
C o n t ro l l e r
C o n te x t I n t e rf a c e ()
B l a c kb o a rd
se tD a t a ()g e tD a ta () nn
A b s t ra ct O b s e rv e r
U p d a t e ()
A b s t ra c t S u b je c t
A t t ac h ()D e ta ch ( )N o ti f y( )
M e a su re m e n t S u b j e c ts u b j e c tS ta te
G e t S t a te ()
nn
F e ed b a ck O b se rv e ro b se rv e rS ta te
U p d a te ()
The initial class diagram
The Feedback Control Example
D a t a H o l d e r
E rro rD a t a M e a su re d D a t a F e e d b a c kD a t a
A b s t ra c t O b s e rv e r
U p d a t e ( )
A b st ra ct S u b je c t
A t t a c h ()D e t a c h ( )N o t i f y ( )
C o n c re t e S t ra t e g y B
A l g o r i t h m I n t e r f a c e ()
C o n c re t e S t ra t e g yA
A l g o r i t h m I n t e r f a c e ( )
F B C o n c re t e S t ra t e g y B
A l g o r i t h m I n t e r f a c e ()
F B C o n c re t e S t ra t e g y A
A l g o r i t h m I n t e r f a c e ()
E r ro rO b se rv e ro b se rv e rS ta t e
U p d a t e ( )
C o n t ro l l e r
C o n t e x t I n t e r f a c e ( )
B la c kb o a r d
se t D a t a ( )g e t D a t a () n
nn
n
M e a su re m e n t S u b j e c tsu b j e c t S t a t e
G e t S t a t e ( )
F e e d b ac k S u b j ec t O b s e rve r
A b s t ra c t C o n t ro l l e r
A l g o r i t h m In t e r f a c e ( )
The refined class diagram ready for code generation
The Feedback Control Example
Object Collaboration Diagram
Measurement : MeasurementSubject
Error : ErrorObserver
F_controller : AbstractController
Strategy1 : ControlStrategyA
FB_Strategy : FBControlStrategyA
5: MeasurePlant ( )
Feedback : FeedbackSubjectObserver
TheBlackboard: Blackboard
9: Notify()
12: GetInput()
13: Analyze()
7: FBApply ()
8: Update ()
10: Update()
11: Getstate()
3: Update ( )
4: GetState ( )
6: Update ()
15: Control (DataHolder*)
14: Update ()
1: Apply (DataHolder*)
2: Notify ( )