[OBJ] Coding - Coding standard (old)

Archived discussions related to Transport Empire. Read-only access only.

Moderator: Transport Empire Moderators

Locked
User avatar
Hyronymus
Tycoon
Tycoon
Posts: 13233
Joined: 03 Dec 2002 10:36
Location: The Netherlands
Contact:

[OBJ] Coding - Coding standard (old)

Post by Hyronymus »

ChrisCF once pulled a coding standard of the net and I have been busy converting it to our new homepage. Some utter crap has been removed but the core issues remain. The coding group needs to evaluate the current coding standard, when needed add to or edit it and finally accept it.

The Coding Standard can be found here.

Members: Grunt, Mek, Pjaytcy, Uzurpator
Last edited by Hyronymus on 23 Sep 2005 17:32, edited 3 times in total.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Post by Zuu »

Conventions

The use of the word shall in this document requires that any project using this document must comply with the stated standard.
The use of the word should directs projects in tailoring a project-specific standard, in that the project must include, exclude, or tailor the requirement, as appropriate.
The use of the word may is similar to should, in that it designates optional requirements.
Seams like the words that are being defined are missing.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
User avatar
Hyronymus
Tycoon
Tycoon
Posts: 13233
Joined: 03 Dec 2002 10:36
Location: The Netherlands
Contact:

Post by Hyronymus »

The words are shall, should and may Zuu.
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

They really should be quoted, then:
The use of the word "shall" in this document requires that any project using this document must comply with the stated standard.
The use of the word "should" directs projects in tailoring a project-specific standard, in that the project must include, exclude, or tailor the requirement, as appropriate.
The use of the word "may" is similar to "should", in that it designates optional requirements.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
User avatar
Hyronymus
Tycoon
Tycoon
Posts: 13233
Joined: 03 Dec 2002 10:36
Location: The Netherlands
Contact:

Post by Hyronymus »

Gald to see the evaluation works :). DaleStan, you're joining TE too ;)?
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

Currently, I'm mostly watching, but I suppose that may change.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
User avatar
Hyronymus
Tycoon
Tycoon
Posts: 13233
Joined: 03 Dec 2002 10:36
Location: The Netherlands
Contact:

Post by Hyronymus »

That could mean 2 things: you stop watching or you join. We'll see in time ;).
Hellfire
Transport Empire Developer
Transport Empire Developer
Posts: 699
Joined: 03 Feb 2003 09:30
Location: Back at the office

Post by Hellfire »

I just noticed something: there is no indentation in the code samples! I recommend chaning samples like:

Code: Select all

class NameOneTwo
{
public:
int StartYourEngines(
Engine& rSomeEngine,
Engine& rAnotherEngine);
}
Into something like:

Code: Select all

class NameOneTwo
{
public:
  int StartYourEngines(
    Engine& rSomeEngine,
    Engine& rAnotherEngine);
}
(Feel free to change according to your own liking. ;))
Feel free to contact me over Email! My current timezone: Europe/Amsterdam (GMT+1 or GMT+2)

Code: Select all

+------------Oo.------+
| Transport Empire -> |
+---------------------+
[ General TE Discussion ] [ TE Development ] [ TE Coding ]
Under construction...
User avatar
Hyronymus
Tycoon
Tycoon
Posts: 13233
Joined: 03 Dec 2002 10:36
Location: The Netherlands
Contact:

Post by Hyronymus »

Ever tried adding it in a css document, Hellfire ;). But it's worth considering.
Hellfire
Transport Empire Developer
Transport Empire Developer
Posts: 699
Joined: 03 Feb 2003 09:30
Location: Back at the office

Post by Hellfire »

The two keywords here are "Fixed width font" and "&nbsp's." ;)

For example:

Code: Select all

<p class="code">
class Something {<br>
&nbsp; int member1;<br>
&nbsp; int member2;<br>
&nbsp; void method(int parameter);<br>
}</p>
Will give, when a proper stylesheet is applied:

Code: Select all

class Something {
  int member1;
  int member2;
  void method(int parameter);
}
Feel free to contact me over Email! My current timezone: Europe/Amsterdam (GMT+1 or GMT+2)

Code: Select all

+------------Oo.------+
| Transport Empire -> |
+---------------------+
[ General TE Discussion ] [ TE Development ] [ TE Coding ]
Under construction...
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

I thought the magic words were "<pre>" and "</pre>"?
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Hellfire
Transport Empire Developer
Transport Empire Developer
Posts: 699
Joined: 03 Feb 2003 09:30
Location: Back at the office

Post by Hellfire »

<pre> is unformatted.. The result will be the same though.
Feel free to contact me over Email! My current timezone: Europe/Amsterdam (GMT+1 or GMT+2)

Code: Select all

+------------Oo.------+
| Transport Empire -> |
+---------------------+
[ General TE Discussion ] [ TE Development ] [ TE Coding ]
Under construction...
User avatar
Hyronymus
Tycoon
Tycoon
Posts: 13233
Joined: 03 Dec 2002 10:36
Location: The Netherlands
Contact:

Post by Hyronymus »

Anything that needs to be added to the coding style guide (and I don't mean format stuff).
User avatar
PJayTycy
Route Supervisor
Route Supervisor
Posts: 429
Joined: 09 Mar 2004 20:30

Post by PJayTycy »

I have never worked on a program that had a "coding style" requirement, I've always done it my way, so I absolutely can't comment on this. Ofcourse, I could say what's different from what I usually do, but that doesn't get us any further, because my formatting rules don't get any better than this:

I usually just follow whatever indentation rules the development environment is best automated for and name my variables/functions however I like them (ie underscores, capitalization, ...).
On holiday from 16/07 till 31/07
User avatar
Hyronymus
Tycoon
Tycoon
Posts: 13233
Joined: 03 Dec 2002 10:36
Location: The Netherlands
Contact:

Post by Hyronymus »

I hope you can imagine where it would lead the code to if everyone in the coding team did that, Pjaytycy ;).
User avatar
PJayTycy
Route Supervisor
Route Supervisor
Posts: 429
Joined: 09 Mar 2004 20:30

Post by PJayTycy »

Hyronymus wrote:I hope you can imagine where it would lead the code to if everyone in the coding team did that, Pjaytycy ;).

Yes, maybe it wasn't so obvious, but I posted that as the reason why I wouldn't comment on this

Topic locked, a final coding style is chosen (15112006).
On holiday from 16/07 till 31/07
Locked

Return to “Transport Empire Development Archive”

Who is online

Users browsing this forum: No registered users and 4 guests