1 / 16

BTS530: Major Project Planning and Design

BTS530: Major Project Planning and Design. Basic Design Pattern Concepts All References and Material unless otherwise specified From: Applying UML and Patterns, 3 rd Edition, chapter 25. Basic Patterns/Concepts. Controller Use Case / Session Façade For protecting from variations

Download Presentation

BTS530: Major Project Planning and 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. BTS530: Major Project Planning and Design Basic Design Pattern Concepts All References and Material unless otherwise specified From: Applying UML and Patterns, 3rd Edition, chapter 25

  2. Basic Patterns/Concepts • Controller • Use Case / Session • Façade • For protecting from variations • For simplicity • Polymorphism

  3. Use Case / Session Controller • What first object beyond the UI controls (receives and coordinates) a system operation? • A “controller” object • Uses use case logic to determine how a message from the UI should be handled • Can be considered a special type of Facade Design Patterns, p. 302

  4. Use Case / Session Controller

  5. Facade • Knows which subsystem classes are responsible for a request • Delegates subsystem requests to appropriate subsystem objects • “Protects” and/or “Simplifies” Design Patterns, p. 461

  6. Façade-protect from variations UI BusinessLogic DataServices

  7. Façade-simplify • The home tv example: • “client” talks to one object—the HomeTheatreFacade • Much simpler than talking to: • Amplifier • Tuner • Dvd player • Etc. • One function “watch movie” initiates all required functions from other classes • Each individual component can be accessed if required Adapted from Head First Design Patterns, by Freeman, Freeman, Sierra, Bates, p258

  8. Subsystem

  9. Façade-simplify Provides a simple interface to a complex subsystem Still have accessto each componentin the subsystem

  10. Polymorphism The Problem: • How do you handle alternatives based on type? How do you create pluggable software components? • if/then/else or case conditional logic is difficult to maintain • difficult to extend a program with new variations • how can you replace one server component with another without affecting the client?

  11. Polymorphism A Suggestion/Solution: • When alternatives/behaviours vary by type (class): • assign responsibilities for the behaviours using polymorphic operations to the types for which the behaviour varies. • polymorphic => same name is given to services (methods) of different objects—the services might vary. • usually implement a common interface or are in a hierarchy with a common superclass (this is language dependent)

  12. Problem1: how to support 3rd party tax calculators? Fig. 25.1

  13. Problem2: in the game Monopoly a different action is initiated when players land on different squares—for example landing on GO initiates “receive $200”. What is the behaviour that varies? Why don’t we want to test for the type of an object and use conditional logic to handle this, all in one class? why? why? Fig. 25.2

  14. Fig. 25.3 What this looks like in a sequence diagram. why? why?

  15. Fig. 25.4-25.7 For individual squares:

  16. Fig. 25.4-25.7 For individual squares:

More Related