Monday, July 6, 2009

Eclipse templates for auto code generation

Working with an IDE tends to make life quiet simple. However we still do not leverage the full potential of using an IDE like Eclipse. During development, i have found creating a few templates really helps to speed up things. Here are the few most common ones i use which are not part of the standard templates. 1) Log4J Logging
a) Create Logger
private static final Logger logger = Logger.getLogger(${enclosing_type}.class);
b) LogInfo${word_selection}${});${cursor}
c) LogError
logger.error(${errorMessage}, ${e});
d) LogDebug
2) Constants
a) Const
private static final ${type} ${name} = new ${type} ${cursor};
3) Map Iteration
a) MapIter
for(Map.Entry entry :
${map:var(java.util.Map)}.entrySet()) {
${key} key = entry.getKey();
${value} value = entry.getValue();
4) JUnit
a) Test Creation
public void test${name}() throws Exception {

The emperor and me beaching

The Devil next door

Kaiser The Emperor