Hi, I have few questions on the VendingMachine design and would like to clarify it. Appreciate your help on this.
- I don’t see the State design pattern covered under the Design Patterns. Am I missing something.
- Why does
Rack
needs aProductID
member in it. Can we have a method saying something like CheckProductOnRack(int productId). This way we can have a Singleton instance ofRack
created. Also, why is Rack tightly coupled with ProductID. A Rack can have many Products - List. - Does customer instantiates the VendingMachine class. Who will be responsible for providing the List and AvailableRacks List info to the VendingMachine. If its done by VendingMachine itself, then I don’t see the relevant methods in it.
- Isn’t the VendingMachine composed of State. The State cannot exist independently though.
- A small correction in the Additional Requirements section of the Class diagram: The Aggregate arrow should be pointed towards the VendingMachine from the State instead of other way around.
- When the actor calls the InsertMoney(double amount) on the VendingMachine class, it inturn calls the InsertMoney(double amount) on the State subclass. What does this method do until the customer selects a product?
Thanks for your help!!
Course: Grokking the Low Level Design Interview Using OOD Principles - Learn Interactively
Lesson: Class Diagram for the Vending Machine