I was asked to make a quick demo for Ping(http://channel9.msdn.com/tags/ping/) on MSDN’s Channel 9 (http://channel9.msdn.com). I used this as an excuse to drink some car bombs along with test the system in a live setting with actual liquid and proper pouring. Here is the system in action.
So how did I create this simple app? I have my relay source code pretty much locked down so all I need to do is fire off one command:
relay.AddCommand(
new RelayCommand(1, 1, 1000),
new RelayCommand(1, 0, 1000),
new RelayCommand(1, 2, 7000)
);
In the future, I’ll create a new class called Bartender so I can do this (and a few other ways):
Bartender.PourDrinkByName("Irish Car Bomb");
Since we know all good object oriented programmers know that objects should only talk to their immediate friends, (Law of Demeter - http://en.wikipedia.org/wiki/Principle_of_least_knowledge), my Drink object call should know how to make the drinks but shouldn’t know how to pour them as there is no need for that class to know about the relays. It has to insert, remove, update, return data for Drinks.
How can I do the PourDrinkByName method call and still obey the law of Demeter? The system will look up how to make the drink. Then I can look up what alcohol is on which valve is on what bank and relay. Since I know what drinks the system currently is armed with, I can also do neat stuff like only return drinks the system can make!
Just for those new to the project, this is a resurrected I did for Maker Faire a few years back. I have the source code and SQL for that version over on Peace Love Code.