Intention Actions

A feature of several current ide's (including IntellijIdea 3.0, and EclipseIde 2.0), which I find really nifty. It's the next step after ReFactoring and TestFirstProgramming.

Simple example:

 class A{
void foo(int i){
String s = bar(i);
}
 }

The IDE marks the bold section red because A does not have a bar() method, and won't compile. Place your cursor on the offending code and make the appropriate guesture (key combo or button click) and select "Create Method 'bar'". Poof, the IDE fills in a skeleton method:

private String bar(int i)
{
return null;
}

Hit tab a few times to select the defaults (or change them if you like) and you're done.

Lesser IDEs just stop at marking an error and you have to fix the problem yourself.

A good ide will have several intention actions for all kinds of different scenarios, including surrounding a method call with try/catch, adding exceptions to method signatures, creating classes, removing unused imports, adding/removing type-casts, adding return statements, changing the type of a method, creating fields from parameters in constructors, etc.

The other cool thing is that it changes your style of programming (similar to the change experienced when switching to TestFirst). You tend to write what you want, then use Alt-Enter to make it compilable. In most cases, a good editor does just what you want.

Could this lead to a style of programming called DeclarativeProgramming?


EditText of this page (last edited August 11, 2003) or FindPage with title or text search