indentation

Brian J. Tarricone bjt23 at cornell.edu
Sun Aug 29 01:13:42 CEST 2004


Olivier Fourdan wrote:

>Hi all,
>
>I'm not forcing any one on using my own coding rules, but I would be
>very grateful if the existing rules could be used for the packages I
>wrote (like xfwm4, xfce-mcs-manager, xfce-mcs-plugins, etc.). 
>  
>
do you want my files in libxfcegui4 changed as well?  if so, that's 
going to be a bit of a problem (see below).

>To name a few of the rules I use:
>
>- I use curly braces even if there is only one instruction after an
>if/while/for because I find it easier to read,
>  
>
that's just a personal preference thing i guess, because i find it 
somewhat the opposite.

>- I expand the source because I don't want tabs. Some editors use 4 or 8
>caracters for a tab and that really break readability
>  
>
don't most editors (at least any that are actualy worth using) let you 
set the tab width?  this is why i like tabs so much.  i prefer 4-char 
indentation, and that's what i tell my editor to display tabs as.  but 
if someone else wants to look at the code, and they prefer 2- or 8-char 
indentation, they can easily tell their editor to display tabs that way, 
and be able to read the code comfortably - without impacting anyone else.

>- I use 4 cars per indentation,
>  
>
me too... sorta ^_~.

>- I don't use nor like Java indentation style.
>  
>
i'm not familiar with this style.

>I think that having different style in the same package breaks
>readability and tends to make the code look "messy", even if it's
>definitely not a big issue.
>  
>
i agree, somewhat.  in a single app, such as xfwm4, probably.  in a 
library, with distinct portions, classes, etc., i think it's just 
important to be consistent within the modules.  now to the 
possibly-causing-friction part: if i'm to work on the portions of 
libxfcegui4 that i've written, there's really no way i can accept having 
them in a different coding style.  i'm happy with what i use, and 
configuring my editor to do something else would be a pain, and would 
overall lower my general productivity.  i don't really feel like running 
indent every time i go to commit something, either.  but i suppose 
that's the only condition under which i'll commit anyone's coding style 
but mine (on a regular basis, anyway) - if someone can provide an indent 
cmdline, so i can just write the code however i see fit and then run 
indent before committing.

>FYI, there are a lot more strict rules on most of the other projects I
>know (Gtk, GNOME, Linux Kernel, etc.)
>  
>
yes.  and there, i can sorta understand, since people tend to come and 
go, and it's important for everything to be uniform to make it easier on 
new coders.  while i'm not saying xfce shouldn't be new-coder-friendly 
(quite to the contrary!), i think, for now, the people who mess with 
xfce code is a pretty stable set of people, and they tend to work on a 
generally small subset of things, so it's not quite critical.  if, in 
the future, the project gets a lot larger (contributor-wise), it may be 
necessary to enforce a common coding style on the entire codebase.  i'm 
really not looking forward to that, because i'm sure my style won't win 
out in the end ^_~.

on a side note, how does the gnome team enforce their coding style 
rules?  it seems to me that they'd have to be pretty lax, at least in 
everything but the core libs.  i find it hard to believe that existing 
projects would have to completely change their already-established style 
just to become a "gnome application."

    -brian

p.s. for the record, i absoltely HATE gtk coding rules.  using a 
combination of spaces and tabs for indentation is absolutely braindead.  
it's totally unreadable for anyone that uses an editor that displays 
things differently.  i'm sorry if that offends some people, but i feel 
very strongly about that.



More information about the Xfce4-dev mailing list