Thursday, November 17, 2011

tools of the trade

Handy commands and shortcuts for folks who develop (Java) software for a living.

*nix
grep
cat
less
more
sort
uniq
sed
awk
wc
ls

All of these are bread-and-butter commands that when chained together allow you to get a lot of ad-hoc stuff done.

eclipse
- Alt-Shift-R - refactor for the var/method underneath the cursor
- Alt-Shift-X - run command short cuts to run tests, apps, etc quickly
- Ctrl-F7 - to cycle views
- Ctrl-F8 - to cycle perspectives
- the debugger's Display view which allows you to run Java expressions within the scope/context of the break-point the debugger is currently stopped at.
- conditional breakpoints: right click on the break point or select it in the breakpoint list, check the Conditional check box and enter the Java expression that will pause the execution when it evaluates to true.  this is a MUST for mutli-threaded development!
- Open Call Hierarchy: right click on a method and use this to see where in your code this method is being called.  I've found this to be very helpful when I'm working on a class that is used in multiple projects (currently open in the workspace of course).

maven
mvn dependency:tree -Dverbose
- shows a very helpful graph of defined and transitive dependencies (as maven sees them)

mvn versions:display-dependency-updates
- shows you which dependencies defined in your pom have updated versions.

mvn versions:display-plugin-updates
- same thing as the dependency flavor but for all the plugins configured in your poms.

misc.
- log4j configurations got you down? Put this JVM command line option in place to make log4j spit out lots of good debugging information: -Dlog4j.debug
- if you find yourself commenting a block of code, consider that you might actually need a function/method. (not sure who said it first but heard it in a code review and wanted to write it down ; )