Presentation is loading. Please wait.

Presentation is loading. Please wait.

SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler

Similar presentations


Presentation on theme: "SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler"— Presentation transcript:

1 SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler http://www.cs.concordia.ca/~gregb/home/soen343h-f06.html

2 Outline GoF Design Patterns –Adapter, Façade, Strategy, Observer Design Review

3 GoF Pattern Summary & Relationships

4 GoF Pattern Classification Behavioral Patterns Creational Patterns Structural Patterns

5 GoF Behavioral Patterns Chain of Responsibility Command Interpreter Iterator Mediator Memento Observer State Strategy Template Method Visitor

6 GoF Creational Patterns Abstract Factory Builder Factory Method Prototype Singleton

7 GoF Structural Patterns Adapter Bridge Composite Decorator Facade Flyweight Proxy

8 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.

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

10 Adapter Adapter provides an interface suited to the application GoodAsGoldTaxProAdapter getTaxes( Sale ) : List of TaxLineItems computeTax(…):double GoodAsGoldTaxPro

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

12 Adapter

13 Facade

14

15 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

16 Strategy

17 How Do We Create a Strategy?

18 Observer Pattern

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

20 What is Wrong With This?

21 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. …

22 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.

23 Observer Pattern (GoF book)

24 Observers: Illustration

25 Sale Example

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

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

28 Design Activities: Inputs & Outputs Product requirements Project plan Architectural factors … ArchitectureDocument –Architectural Style(s) …

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

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

31 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.)

32 Domain Data Source Transaction Script Data Mapper Row Data Gateway Front Controller Template View Transform View Page Controller Presentation Active Record EA Patterns Table Module Table Data Gateway Domain Model

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

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

35 Conceptual Classes to Design Classes Domain Model pattern

36 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.

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


Download ppt "SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler"

Similar presentations


Ads by Google