IntelliJ Community . CodeAlignment

 
CodeAlignment 

HOME INDEX SEARCH CHANGES GO  
Automatic CodeAlignment by IDEA was a hot subject in the newsgroup recently.

Why bother :

  • readability => comfort => productivity
  • each line you write, will be read by you - or others - many times.
  • in a team, even a not great CodingStandard is better than no CodingStandard at all. It helps you feel at home with the code.

Here is a quick poll, to know the feeling and usage of this community.

How to vote : Add you name in the appropriate table cell, after the code sample, and a comment, if you wish. You may choose more than 1 version.

(You may need to visit TWikiRegistration first)

AlainRavet

FYI - I wrote a plugin that can format like Version 7: TabifierPlugin
-- JordanZimmerman - 19 Jul 2002


Question : which code format do you find more readable?


(Readable == helps you answer the following questions :

  1. Is the boolean variable onFlag defined here?
  2. Is there an unassigned variable?
  3. How many strings?
  4. what's the problem with digits?
  5. Are there any numbers defined here?
)

version 1 : no group, no aligment

    String court ="s", veryLong ="abcdefghijklmnopqrstuvwxyz";
    boolean   isOn = true, notAssigned ,isConnectedOrWillBeSoon = true ;
    char digit[] = {'0','1','2','4','5','6','7','8','9'};

version 2 : 1 line/variable

    String court ="s";
    String veryLong ="abcdefghijklmnopqrstuvwxyz";
    boolean   isOn = true;
    boolean   notAssigned;    
    boolean   isConnected = true ;
    char digit[] = {'0','1','2','4','5','6','7','8','9'};

version 3 : group by type

    String court ="s",
           veryLong ="abcdefghijklmnopqrstuvwxyz";
    boolean   isOn = true,
              notAssigned,
              isConnected = true ;
    char digit[] = {'0','1','2','4','5','6','7','8','9'};

version 4 : group v1 and alignment

    String      court       =  "s"  ,
                veryLong    =  "abcdefghijklmnopqrstuvwxyz" ;
    boolean     isOn        =  true ,
                notAssigned         ,
                isConnected =  true ;
    char        digit[]     =  {'0','1','2','4','5','6','7','8','9'} ;

version 5 : 1 line/variable, group v2 and alignment

    String      court       =  "s" ;
    String      veryLong    =  "abcdefghijklmnopqrstuvwxyz" ;

    boolean     isOn        =  true ;
    boolean     notAssigned ;
    boolean     isConnected =  true ;

    char        digit[]     =  {'0','1','2','4','5','6','7','8','9'} ;

version 6 : 1 line/variable, group v3 and alignment

    String      court       =  "s" ,
                veryLong    =  "abcdefghijklmnopqrstuvwxyz" ;

    boolean     isOn        =  true ,
                notAssigned ,
                isConnected =  true ;

    char        digit[]     =  {'0','1','2','4','5','6','7','8','9'} ;

version 7 : 1 line/variable (#2)

    String    court ="s";
    String    veryLong ="abcdefghijklmnopqrstuvwxyz";
    boolean   isOn = true;
    boolean   notAssigned;    
    boolean   isConnected = true;
    char      digit[] = {'0','1','2','4','5','6','7','8','9'};

version 8 : 1 line/variable, (#2) and alignment

    String  court       = "s";
    String  veryLong    = "abcdefghijklmnopqrstuvwxyz";
    boolean isOn        = true;
    boolean notAssigned;
    boolean isConnected = true;
    char[]  digit       = {'0','1','2','4','5','6','7','8','9'};

version 9 : group and alignment

    String  
      court = "s",
      veryLong = "abcdefghijklmnopqrstuvwxyz";
    boolean 
      isOn = true,
      notAssigned,
      isConnected = true;
    char[]  
      digit = {'0','1','2','4','5','6','7','8','9'};

Q/ What is the difference between version 5 and version 8?
A/ v5 inserts a space line between type groups.


f1c

Your votes:
1
2 ScottCurtis VladimirKorenev ValentinKipiatkov MaximShafirov CedricChampeau TimurZambalayev JohannesSchneider EugeneBelyaev MartinSaxer ChrisBartley WalterMundt RadimHanus McAlex ChristianH JacobBayHansen AlexanderEvsukov EdoardoComar CarlosCS VladimirKondratyev NathanBrown DennisLundberg GordonTyler LukasMarek ToonNevelsteen KevinThomas MikeRoberts PeterVerkest ThomasVollmer JoeriSykora HansjoergOppermann MarilynDeQueiroz PaulWheaton? TheCodemonster
3
4 AlainRavet StewStryker FergoFergo
5 CedricChampeau TaoufikRomdhane MikeAizatsky JoachimSauer AndreBriese DimiterD DouglasBullard DanBachelder JorgenLundberg JimMoore TedHill BarryKaplan DaveLorde AikoM JaredRobinson GeorgeMcKinney LeifHanack JuanFlores MikeBrock GeoffreyMitchell MartinEhrlich RandallSchulz
6 AlainRavet YaroslavS
7 JordanZimmerman DimiterD KendallCollett NiPsu
8 AviRosenschein JonasKvarnstrom ScottCurtis DonaldFMcLean FrankFebbraro ChristianAndersson GaelMarziou LeifHanack KevinRiff VesperDEM KevinVinsen NathanSmith DariuszKanicki DonHanson JanLabrie
9 AntiHeld


CategoryPolls


A page like this deserves a visit from The Anal-Retentive Chef:
chef.jpg

e d i t a t t a c h r e f - b y d i f f s m o r e
Have ideas, requests, problems regarding this site? Send feedback.
Copyright © 2000-2003 by the contributing authors. All materials at intellij.org are the property of the contributing authors.