Saturday, July 27, 2013

10 Ways to Boost Up Your Coding Productivity with Eclipse

10 Ways to Boost Up Your Coding Productivity with Eclipse

1. Find

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

Source: http://www.glomelurus.com/

0 comments: