Re: Newbie Key Value-coding and Subclasses Question
Re: Newbie Key Value-coding and Subclasses Question
- Subject: Re: Newbie Key Value-coding and Subclasses Question
- From: David Avendasora <email@hidden>
- Date: Fri, 10 Feb 2006 15:56:01 +0000
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@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden