Arturo,

I am not much in favor of either of your suggestions. How about having an abstract method in your Part superclass called copyToLabel (Label). Then your subclasses just need to implement that and you no longer need instanceof or anything similar. This is what is intended by polymorphism. Your class morphs as necessary into the correct thing without you needing to code it yourself.

Ah ha! I knew that I was just not quite looking at it from the right direction! This is so much better than how I'm doing it. Correct me if I'm wrong: the Label class will have a method that simply calls part.copyToLabel(this), then the part's copyToLabel(Label) method will write back to the given Label all the various values that it knows about, instead of the label needing to know what to do for each type of part.

Although, from your description, it might be better to view it as copyToHumanReadable() and then take it from there.

I'm not sure I understand this. Can you explain more?

Another alternative is to for each part type to put descriptive information into a hashtable. WO can then use WOConditionals to display the appropriate information based on whether a hashtable key exists. For example, WO can mostly automatically do something like (if hashtable.get("unitQuantity") then display hashtable.get ("unitQuantity")).

Yeah, I'm just going to quit while I'm ahead and understand the first option... :)

Thanks!

Dave

_______________________________________________
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