Download presentation
Presentation is loading. Please wait.
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 Business Logic Data Services
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 access to each component in 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
What this looks like in a sequence diagram.
why? why? Fig. 25.3
15
For individual squares:
Fig
16
For individual squares:
Fig
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.