uracoli-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [uracoli-devel] a word about coding style


From: Daniel Thiele
Subject: Re: [uracoli-devel] a word about coding style
Date: Mon, 7 May 2012 22:36:03 +0200

Hi Axel,

in my opinion, "tab" is the better way to indent because of this:
 - it becomes a semantic character for the indent of block (which relates to
a purpose), in Python this is even more important
 - the argument of "tab width config is different in each editor" turns into
the opposite: Everybody likes some different indentation width for code
reading and if we use tabs, everybody can configure the way he likes to read
(in his personal editor).
 - "tab width is 8 spaces" No. Tab is one character you configure as you
like in your editor.
 - Linux kernel coding guidelines use tab as indent
http://www.kernel.org/doc/Documentation/CodingStyle
 - In the past, tab was replaced by spaces for diff tools, as far as I know.
Any diff tool not be able to interpret spaces/tabs mixed should be
considered replaced.


Best regards
Daniel


-----Ursprüngliche Nachricht-----
Von: address@hidden
[mailto:address@hidden Im Auftrag von Axel
Wachtler
Gesendet: Sonntag, 6. Mai 2012 22:21
An: address@hidden
Betreff: [uracoli-devel] a word about coding style

Hallo all,

in the last time various coding styles clash in the repository.
So lets find a good rule set, that makes the external code reader the life
easier to understand wtf is going on ;-)


1) Overall File layout

- In the templates directory there preconfigured skelettons
   for each file. If you find, that they are sub optimal, lets discuss.
- Overall line width should be 80 characters, thats a standard in
   printing most Ascii-Printing applications.

2) Spaces vs. tabs.

- For Python code we agreed to 4 spaces. All other attempts
   can cause funny bug effects.
- For C-Code I would prefer the same (rather the spaces),
   because:
     - tab width config is different in each editor,
     - mostly tab width is 8 spaces, which leads to run easily
       out of the 80 character column border.
     - modern hard disks can handle easily 3 more bytes

3) Curly braces on new lines.
- I would prefer:
    if (foo == bar)
    {
        foo = 42;
    }
   rather then
    if (foo == bar){
        foo = 42;
    }
   imho opininion you the block borders can be better tracked
   if the opening brace is on a seperate line.

- In order to avoid pitfalls, single line blocks
   should not be used:
    if (foo == bar)
        foo = 42;
    else
         bar = 42;
   Replace the above code by

    if (foo == bar)
    {
        foo = 42;
    }
    else
    {
         bar = 42;
    }


Cheers, Axel





reply via email to

[Prev in Thread] Current Thread [Next in Thread]