Re: null testing
Dirk Bruere wrote:
True, but after I have familiarised myself with the 4600 Java classes I
will have died from old age. I have found the best way of learning is doing.
Excuses.
First of all, the operators are not part of "the 4600 Java classes",
they're part of the language itself. There's no excuse for not
knowing the core language - there just isn't, at least not after a
couple or few weeks of study. Whining about the API as an excuse not
to know the language is simply pathetic.
Second, just because you don't expect to know the entire API cold
doesn't mean you should avoid studying it. On the contrary, as you
grow and develop your skills, ongoing study of the API rewards you big
time. Constant study is a part of this business.
After a while you get in the habit of figuring there's probably an API
class that will do some or most of what you need for any given
scenario, and you'll hunt through those "4600 Java classes" before re-
inventing the wheel. If the java and javax packages don't have what
you want, you'll get in the habit of looking through Apache Commons or
the like (so "4600" isn't even the limit - it's actually much, much
higher). As pointed out upthread, Apache commons-lang actually has
methods relevant to the original problem in this thread.
Third, doing without knowing is a recipe for doom. You can perform a
drunkard's walk through the body of knowledge for Java programming,
and if you are very, very lucky you will know a tiny fraction of what
you need by the time you've "died from old age". It's extremely
inefficient. Aggressive, directed study of the basics and beyond will
gain you much more knowledge in much less time. As I mentioned
before, you have the JLS itself available for free, through which you
really must read at least twice in its entirety and to which you
should refer often. Read the tutorials - I've been programming in
Java professionally for over ten years and I still read and reread the
tutorials. Spend time on
<http://java.sun.com/>
and <http://www.ibm.com/developerworks/java/>
and <http://www.javapassion.com/>
and <http://www.mindprod.com/jgloss/jgloss.html>
and such. Measure twice, cut once. Don't deliberately keep yourself
in ignorance.
Fourth, read and study the key books, such as /Effective Java/ by
Joshua Bloch and /Java Concurrency in Practice/ by Brian Goetz, et al.
A mentor once told me that if a developer (or any I.T. professional)
doesn't spend at least 20% over and above their work time in study,
that they're slipping behind. This is wisdom.
Doing is an adjunct to study, not an effective replacement for it, if
you are committed to producing good, solid, bug-free, effective code.
Programming is not for the intellectually lazy. Knowledge is power;
in particular, it conveys a competitive advantage.
--
Lew