• 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: typesafe and chainable keypaths (was: Re: EOSortOrdering and keypaths [SOLVED])
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: typesafe and chainable keypaths (was: Re: EOSortOrdering and keypaths [SOLVED])


  • Subject: Re: typesafe and chainable keypaths (was: Re: EOSortOrdering and keypaths [SOLVED])
  • From: Marc Guenther <email@hidden>
  • Date: Tue, 22 Jun 2010 00:33:24 +0200

On 21.06.2010, at 22:48, Mike Schrag wrote:

>> Good point.  I'd like to see this in Wonder.  Anything that makes the code shorter and easier to read is a good thing.
> "Booking.PERFORMANCE.PERFORMANCE_TYPE().NAME().valueInObject(myBooking)"
> I don't see how you can do this without generating an ERXKey subclass for every type in the reachable type system for KVC ... I briefly experimented with doing that early on, but it generates a TON of classes and I started to get concerned about burning permgen space.

Yes, it does exactly that. It adds 4 classes for every entity, in addition to the two that already existed before. I think that's not too bad for having a nice syntax.

We have about 130 entities and permgen space hasn't been a problem so far.

> You also run into potentially weird problems when two frameworks use keys of the same declared type, but generate their classes in different packages.

I'm not sure I understand. But we don't have that problem, as all our models are in one framework.

> I decided to opt for the .dot(..) method, instead, and just use ERXKeys for with generics.

Yea, but that's so cumbersome to write. And no auto-completion, which is way cool :)


But anyway, all these generated classes are only for the automcompletion stuff and nice syntax. The type safety stuff also works with the dot() method and doesn't need these classes.

So instead of this:
  Booking.PERFORMANCE.PERFORMANCE_TYPE().NAME().valueInObject(myBooking)

you could use the dot() method:
  Booking.PERFORMANCE.dot(Performance.PERFORMANCE_TYPE).dot(PerformanceType.NAME).valueInObject(myBooking)

and still have it return a String. Or:
  Booking.ITEMS.dot(Item.NAME).valueInObject(myBooking)

and it returns an NSArray<String>. Same for all the other examples.


Ah, and in my original email I forgot to mention one nice detail about how valueForKey() and takeValueForKey() handle to-many relations. As already mentioned:

  myBooking.valueForKey(Booking.ITEMS.NAME())

returns an NSArray<String>, but takeValueForKey() on the other hand

  myBooking.takeValueForKey(someString, Booking.ITEMS.NAME())

knows that it needs only a String argument. (yes, this too works with the dot() syntax)


Marc

 _______________________________________________
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

References: 
 >typesafe and chainable keypaths (was: Re: EOSortOrdering and keypaths [SOLVED]) (From: Marc Guenther <email@hidden>)
 >Re: typesafe and chainable keypaths (was: Re: EOSortOrdering and keypaths [SOLVED]) (From: Chuck Hill <email@hidden>)
 >Re: typesafe and chainable keypaths (was: Re: EOSortOrdering and keypaths [SOLVED]) (From: Marc Guenther <email@hidden>)
 >Re: typesafe and chainable keypaths (was: Re: EOSortOrdering and keypaths [SOLVED]) (From: Chuck Hill <email@hidden>)
 >Re: typesafe and chainable keypaths (was: Re: EOSortOrdering and keypaths [SOLVED]) (From: Mike Schrag <email@hidden>)

  • Prev by Date: Re: Create Entity, Delete Entity, Why does validation occur?
  • Next by Date: Re: Create Entity, Delete Entity, Why does validation occur?
  • Previous by thread: Re: typesafe and chainable keypaths (was: Re: EOSortOrdering and keypaths [SOLVED])
  • Next by thread: D2W Editing Non-Model Arrays
  • Index(es):
    • Date
    • Thread