Re: Chuck officially wins
Re: Chuck officially wins
- Subject: Re: Chuck officially wins
- From: Chuck Hill <email@hidden>
- Date: Thu, 4 Dec 2008 19:43:44 -0800
On Dec 4, 2008, at 6:31 PM, Lachlan Deck wrote:
On 02/12/2008, at 10:17 AM, Mike Schrag wrote:
In the long running debate over return null vs return page, I
officially concede to Chuck :) I have long maintained that
returning null really doesn't matter that much, but I just found a
case where it does. If you have a repetition over an array and you
have a delete method that deletes objects from that array, you can
explode if you return null. The loop that calls invokeAction on
all of the items in the list caches the size of the list before
going into the loop. It loops while i < count && woactionresults
== null. That means if you delete item #3 from a 3 item long list
and return null from your delete method, you will
IndexOutBoundsException when it tries to go to the 3rd item in the
list (in a now 2-item-long list). I'm actually kind of surprised I
haven't seen this before ... maybe just a fluke of this particular
use case, but given this error, I would now maintain that it's not
just an issue of performance and now an issue of correctness and
therefore you should never return null. Be aware that this is what
happens when you question Chuck in a public forum :)
A new twist...
Well - I've just come across a situation where context().page()
doesn't do the right thing whereas 'this' does. I'm not sure why.
I tried changes some old code that returned 'this' to
context().page() and it must have been confused because I got the
main component rather than what I normally got.
What did you normally get? Sounds like you have some interesting code
there. return this will make a component on the page the main
component if context().page() != this. Which is why you usually don't
want to return this.
Chuck
--
Chuck Hill Senior Consultant / VP Development
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
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