Indentation levels should always correspond to the logical flow :
   if (rareCondition)
        rareAction();
   action();
    
You would never write it this way :
   if (rareCondition)
   rareAction();
   action();

But this is what we do with try-catch clause.


I found an alternative indentation (see below) in one of the java magazines.
It's so simple it's beautiful. So obvious. So effective.
After using for a week, I can't imagine writing a single try-catch clause the
old way. 



Before (the standard way)
------

    try {
       doStep1ThatCouldFail () ;
       doStep2() ;
  
     } catch (SomeException e){
       doThisOnlyIfSomethingFailed() ;   

     } finally {
       allwaysDoThis ();
    }




After (the reverse indentation way)
-----
 
        try {
    doStep1ThatCouldFail () ;  // line *1
    doStep2() ;

        } catch (SomeException e){
            doThisOnlyIfSomethingFailed() ;   

        } finally {
    allwaysDoThis ();
        }



Move back 30cm, and look at both pieces of code.
Which one makes the more sense to you?


Problem :
  1� typing [return] at the end of line*1 will not put the cursor at the 
     expected level.
  2� IDEA source format does not support this alternative indentation.


Alain Ravet

__________________________________________________
Do You Yahoo!?
Find the one for you at Yahoo! Personals
http://personals.yahoo.com

_______________________________________________
Eap-features mailing list
[EMAIL PROTECTED]
http://www.intellij.com/mailman/listinfo/eap-features

Reply via email to