Page 1 of 1

Code style

Posted: Tue May 24, 2011 3:50 pm
by alt_turo
The current source doesn't have a unified style. Different developers have written code pretty much how they pleased and the result is an inconsistent mess. Here we discuss/flame what should become the official code style. Once decided all developers should stick to this style or risk being mocked mercilessly.

http://universalindent.sourceforge.net/ should be a useful tool for this. We should pick one of the tools it supports and a canonical configuration for that tool which all new code should conform to.

When committing pure formatting changes must not be mixed with functional changes.

The current code is mostly indented with tabs. Therefore all code should be indented with tabs and not spaces.

Curly braces are on their own separate lines. Exception is lines with else where they are on the same line. Should we get rid of this exception?

Personally I prefer style where opening curly is on the same line with control structures (if/else/while etc.) and separate line on class/method definition but the current code is not written like that.

Current code does not consistently use initializer lists in constructors. When initializer lists are used there's inconsistency about the commas. Currently they're mostly at the end of the line but I think they should be at the beginning of the line because this makes for cleaner diffs when adding/removing members. Also there should only be one member initialization per line.

Please post your suggestions. Someone should also take UniversalIndentGui and start tinkering with the options.

Re: Code style

Posted: Tue May 24, 2011 6:02 pm
by Urfoex
I would be for "Artistic Style" (http://astyle.sourceforge.net).
It's easy to use and has lots of options like:
  • Bracket Style
  • Tab
  • Indentation
  • Padding
  • Formatting
  • Other (like line-ending)
A file with desired options could be created and distributed.

As for the style itself I don't know. Reading should not be a problem and after I wrote something and would like to commit I would run astyle with the JackClaw.style and everything would be good ^^

Re: Code style

Posted: Sat Jun 18, 2011 11:30 pm
by AndySmile
What about a java close style?
That doesn't mean that java is my favorite, it isn't at all. But about style and documentation, java is a really good.
So, that you start your file with an header like this one:

/**
* @author
* @version
* @copyright
*/

it's simple, and includes all necessary informations about that file. It is also possible to use doxygen for documentation. it's really a great application, and i think it'll help to get a better overview about that entire project.

So, what do u think?

See ya
Andy =)