Download presentation
Presentation is loading. Please wait.
1
A4 Pre
2
Learning Objectives By the end of this assignment, you will:
Re-design a system to make use of the façade design pattern Use event handling, and the observer design pattern to communicate between modules
3
Learning Objectives By the end of this assignment, you will:
Re-design a system to make use of the façade design pattern Use event handling, and the observer design pattern to communicate between modules I think you need to make use of the event handling. But, it’s nothing you haven’t seen. I am pretty sure this assignment cannot be completed without using event handling. However, do not take this as a challenge. ;-)
4
What’s the idea? Redesign the system for extensibility:
New types of products New forms of payment New forms of communication Alternative hardware (this is already done) Why should we do this? Future-proofing your system Think about abstractions and what assumptions you’re making Someone told you to
5
What it looks like right now
Vending Machine Coin slot Selection Buttons Delivery Chute
6
What it looks like right now
Vending Machine Coin slot Selection Buttons Coin Chutes Pop Chutes Delivery Chute
7
What it looks like right now
Vending Machine Coin slot Selection Buttons Delivery Chute
8
What we’d like to do Vending Machine
9
What we’d like to do 1. Other product types
Vending Machine ”Products” rather than ”PopCans”
10
What we’d like to do 2. New forms of payment
Vending Machine Abstract this to allow others to create new ways to pay (e.g. credit card)
11
What we’d like to do 3. New forms of payment
Vending Machine Abstract this to allow others to interact with the vending machine (e.g. touch screen, voice interaction, etc.)
12
What we’d like to do Abstract these major operations
Vending Machine
13
What we’d like to do Abstract these major operations
Vending Machine
14
What we’d like to do Abstract these major operations
Vending Machine Funds or Payment Facade
15
What we’d like to do Abstract these major operations
Vending Machine Funds or Payment Facade
16
What we’d like to do Abstract these major operations
Vending Machine Funds or Payment Facade …
17
What we’d like to do Abstract these major operations
Vending Machine Funds or Payment Facade
18
What we’d like to do Abstract these major operations
Vending Machine Funds or Payment Facade Communication Facade
19
What we’d like to do Abstract these major operations
Vending Machine Funds or Payment Facade Communication Facade …
20
What we’d like to do Abstract these major operations
Vending Machine Funds or Payment Facade Communication Facade Product Facade
21
Funds or Payment Facade
What we’d like to do Vending Machine Funds or Payment Facade Communication Facade Business Rule Product Facade
22
Funds or Payment Facade
What we’d like to do Vending Machine Funds or Payment Facade Communication Facade Business Rule Product Facade
23
Funds or Payment Facade
What we’d like to do Funds or Payment Facade Communication Facade Business Rule Product Facade
24
Funds or Payment Facade
What we’d like to do Business Rule Funds or Payment Facade Product Facade Communication Facade
25
Funds or Payment Facade
What we’d like to do Business Rule Funds or Payment Facade Product Facade Communication Facade Notice: 1. Funds, Communication and Product Facades don’t talk to one another. 2. Business Rule is what connects things together – i.e. “when there has been a selection, and there is enough money, then vend the pop, and dispense the change” 3. Notice: business rule does not talk to hardware façade 4. This is a layered architecture Hardware Facade
26
A few things to keep in mind
Hardware façade communicates upward frequently through events, so the facades need to register for these events The facades themselves may expose new events (or related events) that other components might be interested in: e.g. Communication Façade might fire a “SelectionMade” event that might be interesting to both: (1) Business Rule, or (2) a touchscreen display (that communicates only with the communication façade) that shows what was selected The purpose of this is to enable extensibility, but do not implement (say) a CreditCard module or a TouchScreen module—that is beyond the scope of this assignment Your goal is to make it such that it would be easy to add such a class into the project, and have it work without having to re-write much
27
Example of Extensibility
CommunicationFacade exists var lcdScreen = new LCDScreen(communicationFacade); constructor: registers for SelectionMade event so that it displays what product was selected when it gets selected (i.e. don’t need to modify CommunicationFacade code at all to accommodate for LCDScreen
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.