I want to create a program that makes an order entry system for drinks. (I will probably make a 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 will not allow me to upload doc as a word, so I have to upload pic. I hope it is easy to view.
I need to know if I am doing UML / design templates correctly before moving on to the coding part.
A drink is my abstract component class. Espresso, houseblend, darkroast are my specific subject classes ..
I also have a class of decorators for seasoning milk, mocha, soy, whip. would be my observer? because they will be interested in changes in data in value?
Now, will espresso, home trim, etc., be my SUBJECT, and will seasonings be my observer? My theory is that value is change and that seasonings should know change?
So subject = esspresso, houseblend, darkroast, etc. // they have a cost ()
Observer = milk, mocha, soy, whip? // they have a cost ()
will there be specific ingredients and milk, mocha, soy, whip? will be a decorator!
So, following good software development practice, “design an interface, not an implementation” or “define things that change from those that don’t”
Do I need a costbehavior interface?
If you look at UML, you will see where I am going and see if I use the observer + Decorator pattern correctly? I think the decorator is right.
pic , :
( , , , )
espresso, houseblend, darkroast, decaf (, getdescription, setcost, costchanged)
()//?
costbehavior (cost)//, ?
(getdescription)
, 2 :
, , , (, getdescription, )
decorator/wrapper.
..

?