I’m a huge fan of the Eclipse IDE, using it not only at work every day but for my own personal projects at home. It has come on leaps-and-bounds over the years, and is a great example of open source software overtaking many commercial options. As I have just changed system recently I’ve been rebuilding everything from scratch, so thought I would share a few of the tools and options I consider must-have.
So Much Choice!
Like many open source projects there is an absolute plethora of tools available to help developers in almost any scenario. In the face of so much choice I take a fairly sparse approach, trying to balance utility with performance and simplicity. I concentrate on core development tools more than I do niche products, and install many fewer than many friends and colleagues.
Power-Up Those Unit Tests
The first product I always install is MoreUnit, a handy little tool which makes creating unit tests a breeze and provides a nice overview of the tests that are in place. Whilst MoreUnit shows the methods missing tests, it does show how effective those tests are. Enter stage left EclEmma, a code coverage tool which shows at a glance which areas and branches of the code under test have been exercised. Utterly invaluable.
If debugging is the process of removing software bugs, then programming must be the process of putting them in.Edsger W. Dijkstra
Squash Those Bugs
Dijkstra was right and that’s why FindBugs is such a useful tool. As a contractor I understand that half of my pay comes from fixing the bugs I create, but I should at least look like like I’m trying not to put them there in the first place. This tool performs static analysis of code, one made without actually executing any code, and looks for understood patterns. It might for example mark as suspect a location where a variable is being to non-null conditionally, raising the prospect of a NullPointerException down the line. Quick to run and with solid documentation for every issue it highlights, it not only helps with issues but will also point out issues with your development style you’d never noticed before.
Getting the Right View of Things
The final thing to do is tweak Eclipse itself to my liking, setting the various options that make life a little easier.
If you would like to avoid stepping through third-party libraries or other code whilst debugging, then the step filtering option is going to be useful. Simply add the packages and patterns you would like Eclipse to ignore through the preferences window, and there’ll be no more tutting and foul language when that unit test fails and you find yourself in the middle of somebody else’s code.
I haven’t decided if this is just personal preference or good practice but the use of static imports really does help to make code a lot cleaner. I find this especially true when writing unit tests given the plethora of static methods that come with it.
As with step filtering, simply set the options to your liking.
Code Style & Clean-Up
Maintaing consistent presentation style across the code base is a snap when the appropriate options are set. Organise imports, provide comment templates or define the wanted placement of braces… a broad range of options provide for very well defined code formatting. Browse the options, spend time tweaking as needed and simply run clean-up before any commit or even have the new defaults applied automatically on save. For the curious or the lazy – like me – my own preferences can be found here.
It’s well worth making sure that the Maven repository details are up-to-date. Open the “Maven Repositories” view, right-click on each entry you see and rebuild.
Views & Perspectives
The “Declaration” view is invaluable, allowing me to view the source code of any method highlighted in the editor window. Open the view, and place it somewhere useful.
Minor Twiddles & Tweaks
One thing I tend to do right off the bat is ensure that I have a custom dictionary defined. Red squiggles annoy me and as I don’t spell like an American its a must. I created mine on my old Linux box with the following command. Just replace the language with your own, and point Eclipse to the output:
$ aspell --lang=en_GB dump master | aspell --lang=en_GB --encoding=utf-8 expand | tr ' ' '\n' > custom.dict
If you like, there’s a base dictionary available for you here.
Taking the time tweak and twiddle the Eclipse IDE offers genuine payoff, with a cornucopia of options avaialble for all of us fiddlers out there. Why not take another look today, and see how much better you can make things work for you?