Code style

Jack Claw was in development between 2006-2008 and was released in the Humble Frozenbyte Bundle for the community to play and build upon.
alt_turo
Posts: 195
Joined: Mon Dec 13, 2010 11:06 am

Code style

Postby alt_turo » Tue May 24, 2011 3:50 pm

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.
Turo Lamminen
Alternative Games

User avatar
Urfoex
Posts: 50
Joined: Fri Apr 15, 2011 11:14 am

Re: Code style

Postby Urfoex » Tue May 24, 2011 6:02 pm

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 ^^
+-----------------------------------------------------------------\
| Debian testing 64Bit on
| * AMD Phenom x4 905e (4x2500Mhz)
| * 6GB Ram
| * AMD/ATI Radeon HD4770 (fglrx)
+-----------------------------------------------------------------/

AndySmile
Posts: 12
Joined: Sat Jun 18, 2011 8:32 pm

Re: Code style

Postby AndySmile » Sat Jun 18, 2011 11:30 pm

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 =)


Return to “Jack Claw Feedback & Development”

Who is online

Users browsing this forum: No registered users and 1 guest