Introduction to Pattern Oriented Analysis and Design (POAD)

25
Introduction to Pattern Oriented Analysis and Design (POAD) Instructor: Dr. Hany H. Ammar Dept. of Computer Science and Electrical Engineering, WVU

description

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 - PowerPoint PPT Presentation

Transcript of Introduction to Pattern Oriented Analysis and Design (POAD)

Page 1: Introduction to Pattern Oriented Analysis and Design (POAD)

Introduction to Pattern Oriented Analysis and Design (POAD)

Instructor: Dr. Hany H. AmmarDept. of Computer Science and Electrical Engineering, WVU

Page 2: Introduction to Pattern Oriented Analysis and Design (POAD)

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

Page 3: Introduction to Pattern Oriented Analysis and Design (POAD)

The Lifecycle of Patterns

Real World Projects

Pattern Mining

Discover Patterns

Incident Occurrence of a Pattern

Preliminary Documenta

tion

Document Analyze/Rule of Three

Author Version

Document

Pattern Polishing

Reusable Version

Pattern Reuse

Feedback

Modification

Phase I: MININGAuthor World

Phase II: POLISHING

Pattern Community

WorldPhase III:

REUSEPattern

User World

Legend

ActivityProduct

(From the Reference “Pattern-Oriented Analysis and Design”, Sherif M Yacoub and Hany H. Ammar Addison-Wesley Inc., 2004)

Page 4: Introduction to Pattern Oriented Analysis and Design (POAD)

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

Page 5: Introduction to Pattern Oriented Analysis and Design (POAD)

Review of Design Patterns

The Command Pattern

From the Design Patterns CD by Gamma et al, Addison-Wesley Inc., 1998

Page 6: Introduction to Pattern Oriented Analysis and Design (POAD)

Review of Design PatternsExamples of Design PatternsThe Observer Pattern: when one object changes state, all its dependents are notified and updated automatically

Model ViewControllerexample

Page 7: Introduction to Pattern Oriented Analysis and Design (POAD)

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

Page 8: Introduction to Pattern Oriented Analysis and Design (POAD)

Review of Design PatternsExamples of Design Patterns

The Strategy Pattern: lets the algorithm vary independently from clients that use it

Page 9: Introduction to Pattern Oriented Analysis and Design (POAD)

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 ?

Page 10: Introduction to Pattern Oriented Analysis and Design (POAD)

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

Page 11: Introduction to Pattern Oriented Analysis and Design (POAD)

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

Page 12: Introduction to Pattern Oriented Analysis and Design (POAD)

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 process a) overall phases, b) analysis, c) design, and d) design refinement

Page 13: Introduction to Pattern Oriented Analysis and Design (POAD)

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.

Page 14: Introduction to Pattern Oriented Analysis and Design (POAD)

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

Page 15: Introduction to Pattern Oriented Analysis and Design (POAD)

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

Page 16: Introduction to Pattern Oriented Analysis and Design (POAD)

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 )

Page 17: Introduction to Pattern Oriented Analysis and Design (POAD)

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

Page 18: Introduction to Pattern Oriented Analysis and Design (POAD)

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

Page 19: Introduction to Pattern Oriented Analysis and Design (POAD)

The Feedback Control Example

FeedforwardStrategy(from POAD1-Feedback)

<<Strategy>>FeedbackObserver

(from POAD1-Feedback)

<<Observer>>

FeedbackStrategy(from POAD1-Feedback)

<<Strategy>>

ErrorObserver(from POAD1-Feedback)

<<Observer>>

Blackboard(from POAD1-Feedback)

<<Blackboard>>

Context

Update NotifyContext

Update

Notify

setData

getData

ConcreteObserver

observerState

Update()

ConcreteSubject

subjectState

getState()

Subject

Attach()Detach()Notify()

ObserverUpdate() nn

Subject

Attach()Detach()Notify()

ObserverUpdate()

ConcreteObserverobserverState

Update()

ConcreteSubjectsubjectState

getState()

nn

ConcreteStrategyA

AlgorithmInterface()

ConcreteStrategyB

AlgorithmInterface()

Context

ContextInterface()

Strategy

AlgorithmInterface()

Context

ContextInterface()

Strategy

AlgorithmInterface()

ConcreteStrategyB

AlgorithmInterface()

ConcreteStrategyA

AlgorithmInterface()

ConcreteDataHolderA ConcreteDataHolderB

Blackboard

setData()getData()

DataHolder

nn

Detailed Pattern-Level diagram

Page 20: Introduction to Pattern Oriented Analysis and Design (POAD)

The Feedback Control Example

ErrorObserver(from POAD1-Feedback)

<<Observer>>

ErrorObserver

observerState

Update()

FeedbackSubject

subjectState

GetState()

AbstractSubject

Attach()Detach()Notify()

AbstractObserver

Update() nn

Update Notify

Instantiating the ErrorObserver pattern

Page 21: Introduction to Pattern Oriented Analysis and Design (POAD)

The Feedback Control Example

FeedforwardStrategy(from POAD1-Feedback)

<<Strategy>>

ConcreteStrategyA

Algori thmInterface()

ConcreteStrategyB

Algori thmInterface()

AbstractController

Algori thmInterface()

Controller

ContextInterface()

Controller

Instantiating the FeedforwardStrategy pattern

Page 22: Introduction to Pattern Oriented Analysis and Design (POAD)

The Feedback Control Example

Blackboard(from POAD1-Feedback)

<<Blackboard>>

Blackboard

setData()getData()

DataHolder

getData

setData

nn

ErrorData MeasuredData FeedbackData

Instantiating the Blackboard pattern

Page 23: Introduction to Pattern Oriented Analysis and Design (POAD)

The Feedback Control Example

DataHolder

ErrorData MeasuredData FeedbackData

AbstractObserver

Update()

AbstractSubject

Attach()Detach()Notify()

nn

AbstractController

Algori thmInterface()

ConcreteStrategyB

Algori thmInterface()

ConcreteStrategyA

Algori thmInterface()

FBAbstractControl ler

Algori thmInterface()

FBConcreteStrategyB

Algori thmInterface()

FBConcreteStrategyA

Algori thmInterface()

Feedback

ContextInterface()

FeedbackSubject

subjectState

GetState()

ErrorObserver

observerState

Update()

Controller

ContextInterface()

Blackboard

setData()getData() nn

AbstractObserver

Update()

AbstractSubject

Attach()Detach()Notify()

MeasurementSubject

subjectState

GetState()

nn

FeedbackObserver

observerState

Update()

The initial class diagram

Page 24: Introduction to Pattern Oriented Analysis and Design (POAD)

The Feedback Control Example

DataHolder

ErrorData MeasuredData FeedbackData

AbstractObserver

Update()

AbstractSubject

Attach()Detach()Notify()

ConcreteStrategyB

Algori thmInterface()

ConcreteStrategyA

Algori thmInterface()

FBConcreteStrategyB

Algori thmInterface()

FBConcreteStrategyA

Algori thmInterface()

ErrorObserver

observerState

Update()

Controller

ContextInterface()

Blackboard

setData()getData() n

nn

n

MeasurementSubject

subjectState

GetState()

FeedbackSubjectObserver

AbstractController

Algori thmInterface()

The refined class diagram ready for code generation

Page 25: Introduction to Pattern Oriented Analysis and Design (POAD)

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 ( )