uracoli-devel
[Top][All Lists]
Advanced

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

[uracoli-devel] a word about coding style


From: Axel Wachtler
Subject: [uracoli-devel] a word about coding style
Date: Sun, 06 May 2012 22:21:28 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.23) Gecko/20110922 Thunderbird/3.1.15

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]