Monday, October 15, 2012

NetBeans Writes My Code for Me

I'm a big fan of Eclipse.  I use it for Perl, PHP, HTML, CSS, JavaScript, ColdFusion ... but when it comes to hardcore Java development, I prefer NetBeans.  NetBeans refactoring tools are superb, and these are the ones I use the most:

ALT+ENTER for red and yellow squiggly underlines.

NetBeans reports all kinds of hints and errors as you're coding with little yellow and ride lines.  Red lines usually mean it won't compile.  Yellow lines usually indicate a coding style suggestion.


Either way pressing ALT+ENTER will usually provide me with options.


Refactor > Encapsulate Fields

Most classes need getters and setters.  NetBeans writes them for me.






ALT+INSERT for more code writing magic

Alt+Insert gives me a menu of things that the IDE can generate for you.  I use it mostly for constructors and override methods.


Instant JavaDocs

Event though JavaDocs come before the classes and methods they describe, if I define my method first, the JavaDocs will write more of the documentation for me.  I put my cursor on the line above the method...


I type /** and press ENTER.


NetBeans writes as much of the JavaDoc as it can based on what it knows about the method.  Then I fill in the rest...


More!

CTRL+SPACE for autocomplete.  I use it everywhere.  In fact, when I use it in a class but not in a method, it provides me a menu similar to ALT+INSERT where it will actually write constructors and override methods for me.

CTRL+R allows me to refactor and rename anything.  I have to be careful when I use this on a shared code repository.  It's easy to cause conflicts.

CTRL+B takes me to the definition of anything, method, class, enum, etc.

ALT+F7 tells me every place a class, interface or method is used.  This one is my favorite.


No comments:

Post a Comment