A4 Pre
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
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. ;-)
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
What it looks like right now Vending Machine Coin slot Selection Buttons Delivery Chute
What it looks like right now Vending Machine Coin slot Selection Buttons Coin Chutes Pop Chutes Delivery Chute
What it looks like right now Vending Machine Coin slot Selection Buttons Delivery Chute
What we’d like to do Vending Machine
What we’d like to do 1. Other product types Vending Machine ”Products” rather than ”PopCans”
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)
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.)
What we’d like to do Abstract these major operations Vending Machine
What we’d like to do Abstract these major operations Vending Machine
What we’d like to do Abstract these major operations Vending Machine Funds or Payment Facade
What we’d like to do Abstract these major operations Vending Machine Funds or Payment Facade
What we’d like to do Abstract these major operations Vending Machine Funds or Payment Facade …
What we’d like to do Abstract these major operations Vending Machine Funds or Payment Facade
What we’d like to do Abstract these major operations Vending Machine Funds or Payment Facade Communication Facade
What we’d like to do Abstract these major operations Vending Machine Funds or Payment Facade Communication Facade …
What we’d like to do Abstract these major operations Vending Machine Funds or Payment Facade Communication Facade Product Facade
Funds or Payment Facade What we’d like to do Vending Machine Funds or Payment Facade Communication Facade Business Rule Product Facade
Funds or Payment Facade What we’d like to do Vending Machine Funds or Payment Facade Communication Facade Business Rule Product Facade
Funds or Payment Facade What we’d like to do Funds or Payment Facade Communication Facade Business Rule Product Facade
Funds or Payment Facade What we’d like to do Business Rule Funds or Payment Facade Product Facade Communication Facade
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
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
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