Usability - Productivity - Business - The web - Singapore & Twins

How CRAPpy is your Java code?

I do a lot of code review lately. LotusScript, JavaScript, Java etc. When I encounter code that is difficult to understand I'm usually met with the defence "But it is working". Funnily it is self-defeating. I never do code review (short of the we-have-fixed-it-now-have-a-look types) of code that works well. Asking us to do code happens because there are problems (I really would love to do a the-proud-code-parents-want-to-show-off-their-really-pretty-baby review once in a while). The typical problems are:
  • Poorly documented code
  • Lack of decomposition
  • Slow code (e.g. getNthDocument)
  • Lack of separation between user time and backend time
  • Lack of caching/object reuse (e.g. Connection pools, Profile Fields)
For LotusScript there is Teamstudio profiler. For Java you can use Crap4J. Crap4J is not a profiler but analyses your code complexity and coverage. Complex code translates into application risk. You get a nice benchmark and a detailed report on the individual methods, so you know how to fix it. Crap4j runs as an Eclipse plug-in. Go get it.

Posted by on 14 May 2009 | Comments (2) | categories: Software


  1. posted by Karsten Lehmann on Thursday 14 May 2009 AD:
    I just posted an article in our Mindoo blog about that topic. It contains a link to an interesting article that compares three automatic bug detection products.

    { Link }
  2. posted by axel on Monday 25 May 2009 AD:
    For javaScript there is jslint.com also (though I don't understand some of the errors the beast discovers).