Tuesday, July 29, 2008

Eclipse Tools You Should Be Using

I've written enough Java code in Emacs, Notepad, and Nano to know a good thing when I see it -- and Eclipse is a good thing! Pretty colors, line numbering, and CTRL+Space!! But seriously, there are a lot of cool things you can use with the software to make it even better.

Saving Tactics
It may seem a bit tedious, but I've got my Eclipse set up to do a bit of formatting every time I tap CTRL+S (which is a lot). It organizes my imports, formats my if statements, cleans up my whitespace, and, of course, saves the file. There are a number of options that differ version-to-version so I won't go into specifics but this is a nice way to keep your code clean and readable, especially working in a team environment.

Write buggy code? Fall into silly bug traps? Too lazy for JUnit? Or just like to try new plug-ins? Try out FindBugs! You can run it fairly quickly over your project and let it discover common ocde flaws, bad paterns, code smells, and code that's just on the fritz. Trust me.

Code Templates
Whether its method signature templates, comment defaults, or javadoc headers, using project-specific class templates are a great way to give your code formatting consistency. For example, I am working on an open-source project and need to include appropriate licensing headers atop each class. So instead of using copy-and-paste each time I make a class, all classes I create in my project automatically start with this text.

Of course, there's tons of things I haven't touched on here but these have greatly impacted my coding and make the process not only quicker and easier for me, but gives me better quality code as well. Maybe some of you can benefit as well! I also left some references you may find useful. Feel free to add others in the comments. 'Til next time!

Carl Scott
Software Developer, Solertium Corporation
View Carl Scott's profile on LinkedIn View Carl Scott's ohloh profile


1 comment:

  1. Subversive just keeps getting better. It projects Eclipse refactorings into the repository very nicely. I recently had occasion to review Subversive with some clients who were new to Eclipse. Based on prior experiences, I was worried when I committed a fairly complex refactoring involving both changes and moves, but they updated without trouble.

    Perhaps you should create a FindBugs pattern that detects cut and paste coding, just for my benefit ...