• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Newbie Key Value-coding and Subclasses Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Newbie Key Value-coding and Subclasses Question
      • From: Arturo Perez <email@hidden>
References: 
 >Newbie Key Value-coding and Subclasses Question (From: David Avendasora <email@hidden>)
 >Re: Newbie Key Value-coding and Subclasses Question (From: Arturo Perez <email@hidden>)
 >Re: Newbie Key Value-coding and Subclasses Question (From: David Avendasora <email@hidden>)
 >Re: Newbie Key Value-coding and Subclasses Question (From: Arturo Perez <email@hidden>)
 >Re: Newbie Key Value-coding and Subclasses Question (From: David Avendasora <email@hidden>)
 >Re: Newbie Key Value-coding and Subclasses Question (From: Arturo Perez <email@hidden>)

  • Prev by Date: Re: Some help with Optimization
  • Next by Date: Re: Newbie Key Value-coding and Subclasses Question
  • Previous by thread: Re: Newbie Key Value-coding and Subclasses Question
  • Next by thread: Re: Newbie Key Value-coding and Subclasses Question
  • Index(es):
    • Date
    • Thread