Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Design question..Food outlet..multiple products

Status
Not open for further replies.

Babliac

Programmer
Jan 28, 2007
2
IE
Here's myt scenario:

A system for a food outlet where the outlet can define their own menus.

The system knows nothing about food. How do I deal with the following in terms of design/applicable pattern:

A menu contains menu items.

Some menu items have options.

Options are complex i.e. a pizza has toppings and the customer can choose say 5 from a list of 7..extra chilli? also, what about diameter and crust type.

Or in the case of a sandwich, the options might be bread type and then fillings..choose 5 from a list of 6 etc. What about butter?

How do i deal with this given that the system won't know what a pizza is i.e. I don't want to create a pizza class since the system is generic i.e. the food outlet defines the menus themselves.

Any help greatly appreciated,
 
IMO, You're creating a Bill of Materials.

There are lots of examples on how to do this.

 
Thanks for the reply Craig0201! But..

I can't find much info on this bill of materials pattern you're refering to besides a patters that concerns the software process (which obviously has nothing to do with this problem).

Could you tell me if this pattern comes under another name? or possibly point me in the direction of a reference?
 
If you are looking for patterns that support Bill of Materials then Composite [GoF] is probably what you need. It allows you to deal with a leaf node in the same way as a branch node. It either handles the request itself or iterates over its children. So you can ask a node representing a pizza for its cost, and it will iterate over its ingredients to find out.

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
How do i deal with this given that the system won't know what a pizza is i.e. I don't want to create a pizza class since the system is generic i.e. the food outlet defines the menus themselves.

It sounds to me like you've got a naming problem. What name to use for the class that describes a food item? Hmmm?

Once you have that, then things will probably start falling into place.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top