• 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: How would you handle such situation?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How would you handle such situation?


  • Subject: Re: How would you handle such situation?
  • From: Florijan Stamenkovic <email@hidden>
  • Date: Wed, 3 Aug 2005 20:36:21 +0200


On Aug 03, 2005, at 18:58, Dev WO wrote:

Hi list,
After trying to figure out the best way to handle the following, I came up with... nothing.


I have a parent class Product and subclasses
    -ProductTypeA
    -ProductTypeB
and a couple more types;)

I'd like to display the informations (the shared one (from Product) like "price", and the specific to a type ones, lets say "speed") of the product.
I was first thinking about doing a template for each type of product, but this isn't really good as I would have to update every template whenever I update one.
So I was thinking about creating one template that would get all the attributes (with conditionals) and create instance variables for every attributes and conditionals inside the template component.
Then I wanted to do something like: (pseudo code;))
if object instanceof ProductType1 then
cast object to productType1 variable
set all the attributes and conditionals


I think it could work, but I'm not really sure I'm going the right direction...
So many times people of the list showed me a lot more simpler and efficient way to go, so maybe this time again.


Anyone with a point of view?

EOCustomObject has a nice few methods that return the names of all attributes, or the names of all relationships (separate for to one and to many)... Just have to dive into the API. So, if you are not dealing with relationships too much, I think it could be possible and even relatively simple to make a template using returned attribute names and avoid using "kind of" operator in total. If you make a model with smartly chosen attribute names you could even parse them into labels, so you don't have statically typed strings at all.


Oh yes, one more thing... Take a look at how your EOModel generated classes define access methods... All the methods just invoke "storedValueForKey" to access fields. Which would also imply that you don't have to cast anything from EOGenericRecord (subclass of EOCustomObject), but just use KVC with the keys returned by the above mentioned methods of EOCustomObject. Complications of course arise if you need to use that template to also change values, let's say in newly added records. Anyway,

In the end you might end up with a model independent template. Something like D2W :)

Additional model dependent logic could of course bring in better handling and display (let's say custom sorting of label - value pairs or I don't know whatnot), at the cost of reusability.

Hope you have fun with this, it sounds interesting. Creative :)

Flor


Thanks

Xavier


_______________________________________________ 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:
    • A Case For Wonder/D2W (was: How would you handle such situation?)
      • From: Anjo Krank <email@hidden>
References: 
 >How would you handle such situation? (From: Dev WO <email@hidden>)

  • Prev by Date: Re: How would you handle such situation?
  • Next by Date: Re-WOBuilder 5.3?
  • Previous by thread: Re: How would you handle such situation?
  • Next by thread: A Case For Wonder/D2W (was: How would you handle such situation?)
  • Index(es):
    • Date
    • Thread