Tuesday, February 7, 2012

Eclipse : Speedup your coding..


Many of java developer write same code over and over and over again which kills our productive time instead of concentrating on meat and potatoes of the project goal. Why don’t we do tune our IDE to do such irritating task.

So lets take a step.. We used to write main method in each java file (though Eclipse IDE is already having this facility at .java file creation time) but how can we automate this?
You might have heard about template creation…No? Not a problem lets learn here...

You will see the following window.
   
Select templates and click on new... button to add your own template
Now click ok and apply and ok of main window. Here ${ClassType} is your variable name which will be used for Re-fectoring. You can change at one place all the related value will be replaced.
Now IDE is ready to
So go to your editor, write your template name and press ctrl+space (you will gate following screen)
 

Code templates are little chunks of reusable code that have certain pieces left open for you to fill in given the scenario with which the template is being used. As complicated as they may sound, they are actually quite simple to use. I'll show the power of templates through the use of the built-in 'for' template.

Writing a for loop to iterate over an array or collection can be a tiring process. Parenthesis, semi-colons, index variables, and brackets cluttered everywhere. To use the 'for' template, simply type 'for' in the Eclipse editor and press Ctrl+Space :
  
Once you've selected one of these 'code templates' from the quick assist drop down, you are then presented with active template code in the editor. The 'templated' values are automatically filled in, and switching between them is as easy as using the 'TAB' key.


 
That’s all ...
In my next post when I will discuss to tune our code, stay tuned! :)