Bob Milton <Do********@newsgroup.nospam> wrote:
Exceptions are rather expensive. It would be better to have the manager
class query the database. If there is no info, return null. Otherwise create
a class object and fill in the info that was returned.
I think it really depends on how exceptional it is to ask for something
which isn't there. If it indicates a significant programming error, and
the whole request should be aborted anyway, then there's nothing wrong
with using an exception IMO.
The "exceptions are expensive" idea is a bit of a myth in my view.
They're only going to end up being expensive in a significant way of
you throw many, many thousand exceptions. As a rough indication, my
laptop can throw of the order of 100,000 exceptions in a second. If
you're throwing anything *like* that number, you're using exceptions in
the wrong way in the first place, and have bigger worries than
performance, IMO.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too