SOEN 343 Software Design Section H Fall 2006

  • Slides: 37
Download presentation
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler http: //www. cs.

SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler http: //www. cs. concordia. ca/~gregb/home/soen 343 h-f 06. html

Outline • Go. F Design Patterns – Adapter, Façade, Strategy, Observer • Design Review

Outline • Go. F Design Patterns – Adapter, Façade, Strategy, Observer • Design Review

Go. F Pattern Summary & Relationships

Go. F Pattern Summary & Relationships

Go. F Pattern Classification • Behavioral Patterns • Creational Patterns • Structural Patterns

Go. F Pattern Classification • Behavioral Patterns • Creational Patterns • Structural Patterns

Go. F Behavioral Patterns • Chain of Responsibility • Command • Interpreter • Iterator

Go. F Behavioral Patterns • Chain of Responsibility • Command • Interpreter • Iterator • Mediator • Memento • • Observer State Strategy Template Method • Visitor

Go. F Creational Patterns • • • Abstract Factory Builder Factory Method Prototype Singleton

Go. F Creational Patterns • • • Abstract Factory Builder Factory Method Prototype Singleton

Go. F Structural Patterns • • Adapter Bridge Composite Decorator Facade Flyweight Proxy

Go. F Structural Patterns • • Adapter Bridge Composite Decorator Facade Flyweight Proxy

Adapter • Context / problem How to resolve incompatible interfaces, or provide a stable

Adapter • Context / problem How to resolve incompatible interfaces, or provide a stable interface to similar components with different interfaces? • Solution: Convert the original interface of a component into another interface, through an intermediate adapter object.

Adapter • Suppose we have a tax calculation class (or external library) but the

Adapter • Suppose we have a tax calculation class (or external library) but the interface is not well suited for our application.

Adapter • Adapter provides an interface suited to the application Good. As. Gold. Tax.

Adapter • Adapter provides an interface suited to the application Good. As. Gold. Tax. Pro. Adapter get. Taxes( Sale ) : List of Tax. Line. Items Good. As. Gold. Tax. Pro compute. Tax(…): double

Adapter (For More than One Class) • What if more than one class (library)

Adapter (For More than One Class) • What if more than one class (library) needs to be adapted?

Adapter

Adapter

Facade

Facade

Facade

Facade

Strategy • Context / problem: How to design for varying, but related, algorithms or

Strategy • Context / problem: How to design for varying, but related, algorithms or policies? How to design for the ability to change (even dynamically) these algorithms or policies? • Solution: Define each algorithm/policy/strategy in a separate class with a common interface

Strategy

Strategy

How Do We Create a Strategy?

How Do We Create a Strategy?

Observer Pattern

Observer Pattern

Observer • How shall we have the display be updated? • Why not …

Observer • How shall we have the display be updated? • Why not … have the Sale inform the display when it changes value.

What is Wrong With This?

What is Wrong With This?

Observer Pattern • Context / Problem: Different kinds of subscriber objects are interested in

Observer Pattern • Context / Problem: Different kinds of subscriber objects are interested in the state changes or events of a publisher object, and want to react in their own way when the publisher generates the event. …

Observer Pattern • Solution: Define a “subscriber” or “listener” interface. Subscribers implement this interface.

Observer Pattern • Solution: Define a “subscriber” or “listener” interface. Subscribers implement this interface. The publisher can dynamically register subscribers who are interested in an event, and notify them when an event occurs. • Clarification: Publisher can dynamically process registration requests from subscribers.

Observer Pattern (Go. F book)

Observer Pattern (Go. F book)

Observers: Illustration

Observers: Illustration

Sale Example

Sale Example

Recall … • Way back in week 5 we asked the question … How

Recall … • Way back in week 5 we asked the question … How do I come up with a design?

How Do I Come Up With a Design? • What are the inputs to

How Do I Come Up With a Design? • What are the inputs to the activities of design? • What are the outputs?

Design Activities: Inputs & Outputs • Product requirements • Architectural factors … • Architecture.

Design Activities: Inputs & Outputs • Product requirements • Architectural factors … • Architecture. Document • Project plan – Architectural Style(s) • …

Design Input: SRS • What is contained in the SRS? (name some of its

Design Input: SRS • What is contained in the SRS? (name some of its parts)

Design: From SRS to. . . • Domain Model • Design Model • Use

Design: From SRS to. . . • Domain Model • Design Model • Use Case Model • Control Style / Pattern • User-interface design …

Design Model Classes • Domain Model often used as first approximation to Design Model.

Design Model Classes • Domain Model often used as first approximation to Design Model. • Domain Model contains – Conceptual classes • Conceptual classes used as basis for similarly named design classes. • (E. g. Larman, Chapter 16, p. 222. )

Domai Presentati Data Source on n EA Patterns Page Controller Template View Front Controller

Domai Presentati Data Source on n EA Patterns Page Controller Template View Front Controller Transform View Transaction Script Domain Model Data Mapper Active Record Table Module Row Data Gateway Table Data Gateway

Enterprise Applications: Domain Model • Requirements Domain Model • Design Model: classes Domain Model

Enterprise Applications: Domain Model • Requirements Domain Model • Design Model: classes Domain Model pattern

From Requirements to Design Requirements artifacts: e. g. Design artifacts: e. g. • Software

From Requirements to Design Requirements artifacts: e. g. Design artifacts: e. g. • Software Architecture Document • Domain Model • Design Model • Use Case Model • User-interface design …

Conceptual Classes to Design Classes • Domain Model pattern

Conceptual Classes to Design Classes • Domain Model pattern

Representational Gap • Larman, Section 17. 2: The object developer has taken inspiration from

Representational Gap • Larman, Section 17. 2: The object developer has taken inspiration from the real-world domain in creating software classes. Therefore, the representational gap between how stakeholders conceive the domain, and its representation in software, has been lowered.

From Rich Conceptual Domain Model to Rich set of Domain Model classes

From Rich Conceptual Domain Model to Rich set of Domain Model classes