Menu

Work in progress

Recently I started to develop with Eclipse Kepler (version 4.2). I was quite astonished how much warnings it showed up for my code. Usually I trusted on the default configuration of Netbeans. Now I learned that for Netbeans I have to enable additional warnings. Like the javac compiler warnings which I found to be switched off.

I enabled these and moreover I checked my code with PMD and FindBugs. That brought more interesting hints. I improved one weakness after another. Now Findbugs doesn't show up weak points - in the default configuration. I have to learn about this.

This let me change the way some objects are created. Some classes had constructors which throw an IllegalArgumentException. I (hopefully) did it in a safer way along the CERT Coding Standards but ... If I attempt to create an object an get an exception - what does it mean? Maybe wrong arguments, technically. But domain-specific? I want a new car => boom! Exception. What was my fault? That I need a new car?

So I decided to provide a protected constructor with no checks of argument values and some public factory methods which will check the argument values and throw an IllegalArgumentException if necessary.

If there is a clone() method one of these factory methods will accept an object of this class as argument (objectToClone) and return objectToClone.clone as result. If the object is null we get an IllegalArgumentException.

Posted by Michael Groß 2014-03-05

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.