Chuck officially wins
Chuck officially wins
- Subject: Chuck officially wins
- From: Mike Schrag <email@hidden>
- Date: Mon, 1 Dec 2008 18:17:58 -0500
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 :)
ms
_______________________________________________
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