The debugger is your friend; even in Java
I am continually fascinated by how little many people use a debugger1 when they’re trying to understand their code. Today, I watched an otherwise very intelligent person stare at some Java code for 15-20 minutes trying, apparently, to mind-meld with the JVM and understand what went wrong and why he was getting a glorious NullPointerException, something I still find gloriously amusing.
“Why don’t you set a breakpoint and look at what’s going on right there?” I asked. You would think I was talking Aramaic. Even I, arch-hater of Java—and Eclipse—was able to divine the way to do this task and within 15 seconds we had a solution.
Learn to use the debugger, even if you’re working in a dead language like Java. It might not be a live object universe like Smalltalk, but it is 100x better than simply guessing.
1 If you’re cursed with either C or C++, invest your hard-earned money in TotalView if you have to do anything with multi-threaded code. It is unparalleled by any other debugger.
This entry was posted at 7:27 pm on 6 May 2008 and is filed under Programming. You can follow any responses to this entry through the post-specific RSS 2.0 feed.
Both comments and pings are currently closed.
I’ve written Java professionally at a couple of different places, and I’ve never been able to live without the debugger. It’s not like working with Smalltalk, no, but if you didn’t make too many changes (like change a method signature), you can usually hot swap code in a running servlet container.
I used to work at a small company with a lot of inexperienced devs, none of whom knew how to work a debugger. Most of them couldn’t even work Eclipse. I’ve also worked at a more mature consulting company, and the debugger was just a part of our daily lives.
It’s just a tool every good developer needs to be have in his arsenal, and it doesn’t really matter what his/her primary language is. Why all the hate against Java? Geez.
(Note: Don’t take me the wrong way; I jumped ship to Scala. But I still don’t think Java is the worst language in the world)