• 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: Here's one newbie trap to avoid
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Here's one newbie trap to avoid


  • Subject: Re: Here's one newbie trap to avoid
  • From: Scott Winn <email@hidden>
  • Date: Fri, 26 Jan 2007 16:52:05 -0800

For myself, I wouldn't mind see an EOObjectNotAvailable whenever there are no results either for object or objects. A missing fetch spec probably should be an exception unto itself rather than reusing EOObjectNotAvailable.

It is not that any of the above is a "bug", just unexpected and a little unintuitive (for me anyway). It probably isn't great programming practice to rely on exceptions being thrown for your code to work, but the subtle difference in the naming scheme and the big different in behavior made me think this particular pitfall was worth mentioning.

Scott


On Jan 26, 2007, at 4:36 PM, Chuck Hill wrote:

All of the EOUtilities.objectsWith (note plural objects) don't throw an exception if zero rows are returned. This is documented in the API and seems like the correct behavior to me.

The exception that it is throwing if it can't find the fetch spec does seem like a bug.


Chuck

On Jan 26, 2007, at 4:29 PM, Scott Winn wrote:

EOUtilities.objectWithFetchSpecificationAndBindings
throws EOObjectNotAvailableException - if there is no matching object, so far so good.


You do a fetch with no results and get an EOObjectNotAvailableException. But watch out for. . .

EOUtilities.objectsWithFetchSpecificationAndBindings
it throws EOObjectNotAvailableException, but only if it can't find the fetch specification.


If you are used to the way object (singular) WithFetchSpecAndBindings behaves you are out of luck with this one. You do a fetch with no results and get no exception. You may have been expecting an EOObjectNotAvailableException, but you are never going to get it. Why didn't someone come up with an EONoFetchSpec exception instead? What does objectWithFetchSpecificationAndBindings throw if it can't find the fetch spec? Anything?

It's so subtle it is almost evil. Just glad I didn't waste too much time with it. One more newbie trap to avoid, but at least it is in the documentation.

Scott
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40global-village.net


This email sent to email@hidden


--

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
References: 
 >Here's one newbie trap to avoid (From: Scott Winn <email@hidden>)
 >Re: Here's one newbie trap to avoid (From: Chuck Hill <email@hidden>)

  • Prev by Date: Re: Here's one newbie trap to avoid
  • Next by Date: Re: daylight saving time problem
  • Previous by thread: Re: Here's one newbie trap to avoid
  • Next by thread: Upgrading a Panther Server to WO 5.3
  • Index(es):
    • Date
    • Thread