Re: To wrap or not to wrap?
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 shifted 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 shifted
to the corresponding chemistry table where I had a friend. At first I
asked what were the important problems in chemistry, then what important
problems they were working on, or problems that might lead to important
results. One day I asked, "if what they were working on was not important,
and was not likely to lead to important things, they why were they working
on them?" After that I had to eat with the engineers! -- R. W. Hamming