I want to make a program that does an order entry system for beverages. ( i will probably do description, cost)
I want to use the Decorator pattern and the observer pattern.
I made a UML drawing and saved it as a pic for easy viewing. This site wont let me upload as a word doc so i have to upload a pic – i hope its easily viewable….
I need to know if i am doing the UML / design patterns correctly before moving on to the coding part.
Beverage is my abstract component class.
Espresso, houseblend, darkroast are my concrete subject classes..
I also have a condiment decorator class
milk,mocha,soy,whip. would be my observer? because they would be interested in data changes to cost?
Now, would the espresso,houseblend etc, be my SUBJECT and the condiments be my observer?
My theory is that Cost is a changes and that the condiments need to know the changes?
So, subject = esspresso,houseblend,darkroast,etc.. // they hold cost()
Observer = milk,mocha,soy,whip? // they hold cost()
would be the concrete components and the
milk,mocha,soy,whip? would be the decorator!
So, following good software engineering practices “design to an interface and not implementation” or “identify things that change from those that dont”
would i need a costbehavior interface?
If you look at the UML you will see where i am going with this and see if i am implementing observer + Decorator pattern correctly? I think the decorator is correct.
since, the pic is not very viewable i will detail the classes here:
Beverage class(register observer, remove observer, notify observer, description)
these classes are the concrete beverage classes
espresso, houseblend,darkroast, decaf(cost,getdescription,setcost,costchanged)
interface observer class(update) // cost?
interface costbehavior class(cost) // since this changes?
condiment decorator class( getdescription)
concrete classes that are linked to the 2 interface s and decorator are:
milk,mocha,soy,whip(cost,getdescription,update)
these are my decorator/ wrapper classes.
Thank you..

Is there a way to make this picture bigger?
I can see decorator comes into play here, but I am not too sure about using observer here. It seems forced.
Several things:
My suggestion is to read up again on the Head First Design Pattern book (which I think where you get this examples :), very similar domain) and get a better understanding on both patterns and when to use them.
Below is an example of decorator and observer working together. The drink combination is an implementation of decorator. The ordering system is an observer (where the order will notify the pager and the pager will do something). The scenario here is a StarBuck coffee shop where they’ll give you a pager so you can go around doing something while your drink is being processed and you will get notified by the pager once the drink is ready.
Save the sample as drink.cs and you can easily compile this using csc ( C:\Windows\Microsoft.Net\Framework\v3….\csc /target:exe /out:drink.exe drink.cs) and run it or use VS or whatever :).