On Thu, 8 May 2008, Aaron Fude wrote:
> In my personal development efforts, I frequently wrap basic java
> functionality. For example, I have a
>
> String MyIO.urlToString(String url)
>
> or
>
> byte[] MIO.urlToBytes(String url)
>
> etc. These functions catch exceptions and return null if something
> goes wrong. I have other functoins that, for example, load database
> queries into maps.
>
> My gereneral questions are these. Does everybody pretty much end up
> writing convenience wrappers like these for themselves?. If yes, why
> aren't utilities like these commonly available as more or less
> standard libraries? And if no - why not? Is it a bad idea to use these
> and is it for some reason better to, e.g., always form URL's, open
> connections, capture exceptions, etc.
What everyone else said. Exceptions are a good way to do error handling.
Null returns are not. You're shooting yourself in the foot.
tom
--
For the first few years I ate lunch with he mathematicians. I soon found
that they were more interested in fun and games than in serious work,
so I ****fted to eating with the physics table. There I stayed for a
number of years until the Nobel Prize, promotions, and offers from
other companies, removed most of the interesting people. So I ****fted
to the corresponding chemistry table where I had a friend. At first I
asked what were the im****tant problems in chemistry, then what im****tant
problems they were working on, or problems that might lead to im****tant
results. One day I asked, "if what they were working on was not im****tant,
and was not likely to lead to im****tant things, they why were they working
on them?" After that I had to eat with the engineers! -- R. W. Hamming


|