Ian Joyner wrote:

On 13/02/2006, at 4:09 PM, David Avendasora wrote:
I and a new OO programmer and I *really* appreciate everyone's advice on OO design!

In this case, these three part types have some very specific differences. It is not one part that changes. My application is being built to manage the manufacturing in a bakery. - Raw parts are sugar, flour, oil, etc. and are usually procured from outside vendors. - Intermediate parts are things like dough, toasted coconut and such where an intermediate part has a Bill of Materials and requires work within the manufacturing line to have produced. - Finished parts things like like cookie, bar, etc. and are parts made up of any number of Raw and/or Intermediate parts. Since they are sold to customers they also have to have additional attributes like UPC code, customer specific attributes.

Does this still sound like something that would work better as an implementation of the Status Pattern, or should I stick with Inheritance?

OK, that clarifies it and I think your inheritance design is probably fine. Do these three kinds of things have features in common? Data values (either attributes or typed functions) and procedures (untyped (void) functions). What I do think you'll have is for the intermediate and final parts, as 'has-a' relationship 'ingredients'. Make sure you don't mix up the is-a (inheritance) with has-a (component-of) relationships. Otherwise inheritance is fine.

Ian

Right, and I think, generally speaking and as discussed in Head First Design Patterns, one should favor composition over inheritance. Inheritance can lock you into design choices since no common language allows modification of inheritance hierarchies at runtime.

So, I would design Finished as a container for Ingredients and Ingredients as containers for RawMaterials. Using Ian's language Finished has-A Ingredient etc.

-arturo

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to