1 / 37

SOEN 343 Software Design

SOEN 343 Software Design. Section H Fall 2006 Dr Greg Butler http://www.cs.concordia.ca/~gregb/home/soen343h-f06.html. Outline. GoF Design Patterns Adapter, Façade, Strategy, Observer Design Review. GoF Pattern Summary & Relationships. GoF Pattern Classification. Behavioral Patterns

sterling
Download Presentation

SOEN 343 Software Design

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SOEN 343Software 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. Chain of Responsibility Command Interpreter Iterator Mediator Memento Observer State Strategy Template Method Visitor GoF Behavioral Patterns

  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 / problemHow 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. GoodAsGoldTaxProAdapter getTaxes( Sale ) : List of TaxLineItems GoodAsGoldTaxPro computeTax(…):double Adapter • Adapter providesan interface suitedto the application

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

  12. Adapter

  13. Facade

  14. Facade

  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. Product requirements Project plan Architectural factors … ArchitectureDocument Architectural Style(s) … Design Activities: Inputs & Outputs

  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. EA Patterns Page Controller Template View Presentation Front Controller Transform View Domain Model Transaction Script Domain Data Mapper Table Module Active Record Table Data Gateway Row Data Gateway Data Source

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

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

  35. Conceptual Classes to Design Classes • Domain Model pattern • 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

More Related