10 Ways to Boost Up Your Coding Productivity with Eclipse

There is no other IDE I love better other than Eclipse. And I admit that, I felt lucky that I am a programmer in the decade that Eclipse is already invented!! I have been using this tools for 4 years and know exactly each features of it. If there is such a tool which is very powerful, and scalable, and reliable, and is FREE, why wouldn't you use it ??


So, lets talk about this 10 ways.

1. Find

About a few months ago I remembered that we had a deadline to dirtily apply a single sign on interceptor to a bunch of ugly PHP codes in 1 night. They were spread all over the files and there are so many files need to be edited. So we kind of stayed until 8pm to get it done. Lucky thing I'm not a PHP guy, so I didn't have to do it. So I watched a newbie doing it with his primitive PHP code editor. Here what he did. He started to open the first *.php file.

Guess what he did, with his eyes, he scrolled up and down with his mouse to search the interceptor part with his eyes, and found 2 sections about it. Then he applied the new interceptor to the sections, and tested it. But it still gave some errors on the page. So I told him: use the FIND feature. And after he did it, turned out that there were 4 sections more need to be edited.

Human eyes can't be trusted, and prone to errors. To search strings always use the FIND feature.


In eclipse, this feature is even so powerful. Here what we can do in Eclipse:
  • search in the entire workspace, workset, project, or selected resources
  • search with regular expression
  • search within files with a defined pattern
2. Find and Replace

Imagine that you have to edit texts in some files at once with the same patterns. Eclipse provide a preview so you can first check whether all replacements are correct or not before doing it.

And there's the special feature which you might need:

use replace magic{1}Old with maggie{1}New

To replace something like:
magicLinesOld to maggieLinesNew,
magicHouseOld to maggieHouseNew
magicShoesOld to maggieShoesNew
magic{*}Old to to maggie{*}New





3. Code Highlighting

This feature can help to efficiently read the code. If you want to know in which lines the object is being used, just put the cursor on the object, and then every occurence of it will be highlighted.

4. Refactoring

With this feature, you can do these things with some clicks only:
  • rename an object, a class, a variable, or a field.
  • extract a literal string to a constant field.
  • change method's name and parameters.
  • move a method or a field.
  • etc


5. Generate Getters and Setters

Actually there are more generators, but this one is the one I use most of the time. This will be very helpful to create POJO.



6. Formatting

Pretend that you typed some lines of code like this:


Will you arrange that code manually? No!! Just press the shortcut for formatting, usually CTRL + Shift + F, and voila here what you got:


7. Compare

What is so good with Eclipse's file comparer is that:
  • You can compare it by left-right side.
  • You can show next or previous difference.
  • On the right side of the scrollbar there is a clickable link to every differences.
  • There is a menu to copy current or all change(s) from right to left or vice versa.


8. The Warning Icons

Your brain is not designed to be a code compiler, so stop using it to check syntax !!
What's nice about Eclipse is that it even provide warning for ugly codes. If you see some yellow lines on the source editor, it's not a decoration. It means that your code is ugly. Here are some things that can make the code ugly:
  • Local variable is never read, so why keep it ?
  • A serializable class does not declare a static final serialVersionUID field.
  • The imported class is never used, so why keep it? There is also a feature to organize imports, so you don't have to take care of importing classes at all.
  • Used a deprecated method / class.
  • Using raw types of objects which should be parameterized such as: List, Set, Comparator, Class, etc.
  • etc.


9. Local History

"But it worked a few hours ago", you said. With Eclipse, every saving of every files are being logged, so you can show the entire history of a file, and then compare, or rollback to the previous saved version. Amazing isn't it ??



10. The Integrated CVS / SVN Client

There is no other CVS /SVN client I could find which is such rich of features and luckily, it's integrated to the IDE !!

With Eclipse' CVS / SVN client you can:
  • Show the history of 1 file, CVS / SVN history and local history (read number 9).
  • Show the history of 1 project (SVN client only).
  • Compare current version with another tagged version. Or with SVN much better, with every commited version, because every commit will be assigned with a incremented version number.
  • Show all of the tags which are existed within a CVS repository.
  • Synchronize the source code with a less painful way.