Re: method lookup order performance benefit?
Re: method lookup order performance benefit?
- Subject: Re: method lookup order performance benefit?
- From: Jonathan Rochkind <email@hidden>
- Date: Mon, 26 Apr 2004 11:26:22 -0500
I believe that default implementation of KVC is pretty well
optimized. I'd guess that it only goes through that lookup chain the
_first_ time a given key is asked for, for a given class, and
essentially caches that information for subsequent lookups.
I don't think you'd get any significant performance benefit from
naming your keys using conventions "higher up" in the lookup chain.
Even if default KVC implementation _wasn't_ highly optimized, my
guess would be that performance benefits to this type of thing would
be pretty minimal. You could try to test it and see if you want to
be sure. But personally, I wouldn't bother making changes like this
for performance reasons.
--Jonathan
At 9:20 AM -0500 4/26/04, Michael Engelhart wrote:
Hi -
I was looking at Apple's Inside WebObjects Web Applications
documentation last night and was reading the section on the Sync
stage of the request response cycle and noticed mention of the order
in which say takeValuesFromRequest tries to find available
setters/getters or instance variables. They list this order:
SETTERS:
1. public void setKey()
2. private _setKey()
3. _key
4. key
GETTERS:
1. public [...] getKey()
2. public [...] key()
3. private [...] _getKey()
4. private [...] key()
5. [...] _key
6. [...] key
So my question is this. Is there any performance benefit to using
the standard JavaBeans setter/getter methods since they are the
first in the chain of lookups? Not having access to the source of
how WO does this and not being hugely familiar with Reflection
(which is what I'm guessing WO uses internally to make this
decision), it seems that would be the case. But being new to WO
I'm not sure. The reason I'm even asking is that EOModeler doesn't
allow you to choose how you want the source generated. It only
outputs:
key() // getter
setKey() // setter
for the generated Java class file.
Not a huge deal but would rather ( if there is a performance hit to
using method calls that are lower in the chain) just get in the
habit of rewriting out methods using the JavaBeans standard and also
to "always" create setter/getters in WOBuilder. It seems like most
of the books I have don't advise you to select the setter/getter
auto-generation for instance variables when adding them to the
example code that is being shown. It's always shown as optional.
Thanks for any insight.
Mike
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.