Title: RE: [Eap-features] briliant idea : reverse indentation of try-catch-finally
Since you asked...
 
The first piece of code looks much more readable for me.
 
Hope that your collages are using IDEA so they can easily reformat your code ;-)
 
Tal
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Glen Stampoultzis
Sent: Thursday, November 15, 2001 5:50 PM
To: '[EMAIL PROTECTED]'
Subject: RE: [Eap-features] briliant idea : reverse indentation of try-catch-finally

-1  looks harder to read to me.  Perhaps code folding can do something useful with this...

-- Glen Stampoultzis

-----Original Message-----
From: Alain Ravet [mailto:[EMAIL PROTECTED]]
Sent: Thursday, November 15, 2001 8:56 PM
To: [EMAIL PROTECTED]
Subject: [Eap-features] briliant idea : reverse indentation of
try-catch-finally



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