Time for another Antitrust suit

I think it is time to remember Microsoft’s antitrust suit because another one may be coming soon to Apple. Apple has been monopolizing the platform by blocking all applications which competes slightly with it getting passed through the gate. Apple should have confidence that if it has better product than others, people do use it (And no other company better than Apple in make it happen) and let other compete.

California DMV Test Papers

When I moved to California from Jersey and getting ready to take the California Driver’s written test, I didn’t find good sample test papers to get the feel of the test or to evaluate myself to see where I stood. After the exam, I thought I will collect/create some sample test papers to it would ease anybody else who is attempting to take the exam but managed to procrastinate till today.

I wanted to write some generic code so that extra time need not be spent if I had to add additional sample papers. I was in good mood today to deal with the javascript quirks (really, you got to code in understand the quirks) so wrote up javascript to load the xml data file with all questions and render the (supporting both single and multiple choice) questions and evaluate the answers to findout of tester is passed or failed.

It came out pretty good and I’m quite happy with it. Another interesting twist is that first person who going to use is my wife :) She trying to take the exam sometime this week.

I’m planning to add around 6-7 papers over period. Take a look and pass the url along to whoever might benefit.

NullPointerException vs IllegalArgumentException

There has been lots of discussion going on for a very long time weather to use NPE or IAE when a null is passed when a non-null object is expected as an method/constructor argument.

After developing java applications for quite sometime, I have observed that when one sees a NPE in the log file, it usually means some serious bug which should be dealt with.  I strongly think that NPE should only ever be thrown by the JVM when it try to access some properties/methods of a null object (hey did you notice, it is called Null Pointer Exception where pointer means trying to access a property or method on null).

However javadoc for NPE allows applications to throw NPE in other subjective scenarios, which led to misuse of it.

Thrown when an application attempts to use null in a case where an object is required. These include:

  • Calling the instance method of a null object.
  • Accessing or modifying the field of a null object.
  • Taking the length of null as if it were an array.
  • Accessing or modifying the slots of null as if it were an array.
  • Throwing null as if it were a Throwable value.

Applications should throw instances of this class to indicate other illegal uses of the null object.

To move on, if only all developers follow the convention to use only IAE and leave the NPE to the JVM, life would far better for the troubleshooters :)

So next time you validating the constructor/method parameter, forget NPE and use IAE.

    public void doSomething(String anything) {
        if (anything == null) {
            throw new IllegalAccessError("Parameter anything is null");