Talk:CodeStyleGuide

From TDN

White space

Is it worth it to add a section on appropriate use of whitespace? For instance, in the engine you'll see

return true;
return (true);
return ( true );

and

if (x < 3) ...
if ( x < 3) ...
if ( x < 3 ) ...

Is this the kind of thing we want to "standardize" in Torque?

--Jmquigs 12:10, 6 Jul 2005 (CDT)

I think some standards might make sense. For one, "return" is not a function, so only the first of the return statements above should be used.

In terms of spaces within an expression, I usually try to use spaces to group things as they should be grouped, which is a very subjective thing to do but can add clarity. So, for example, I might write (x!=0 && y==3) but (x != 0) someplace else. I prefer both of these to (x != 0 && y == 3) and (x!=0). If my perception of which is better here is held by others, I'd at least think that we could come up with a rule that handled most cases like this. But is it worth it is another question.

So there are two principles to consider here:

1) Having a standard way of formatting code means everything looks more uniform, which to me makes it look more professional. I think this is important for Torque, and is an area where it suffers (maybe not compared to other game engines, but compared to ideal code).

2) Going overboard with standards means that people feel like they are towing the line for unimportant, bureaucratic reasons. There is also a cost associated with maintaining such a standard. You either have to monitor what people are doing and correct errors, or you don't monitor and people don't follow the rule (in which case, why have the rule?).

There is a balance which needs to be struck here. Not sure if white space standardization would be more of the first or more of the second.

Thoughts?

--Cfagot 17:05, 7 Jul 2005 (CDT)


I personally use the method:

if ( x < 3 ) ...

but sometimes less policy is more. Maybe in addition to the "required-guidlines" there should be a "suggested guidelines" at the bottom of this article that covers stuff like that for people motivated enough to follow it. --RavenSlay3r 13:07, 3 March 2006 (EST)

File Architecture

So, I've been thinking about my edit of the Global’s are bad text I made earlier and it occurred to me it might be more of a Best Practices item than the Style item? Any comments?

Also, maybe instead of getting specific about how to treat global variables and functions stylistically it would be better to have a sidebar talking about the better alternative. i.e. If you are creating a global function etc. it probably means that either you should create a new classes which is more useful too all, or add the functionality to an existing class. Classes after all are buckets for organizing functionality together in a useful and intuitive manner. --Mr.Phil 21:54, 18 Aug 2005 (CDT)


I thought your text on globals was good, but a sidebar that goes into more detail for those intrested would not be a bad idea. --RavenSlayer 13:14, 3 March 2006 (EST)


#includes vs. #defines

Just to cross-post: http://www.garagegames.com/mg/forums/result.thread.php?qt=40879 I rasied some questions abut this guideline, I think their order should be reversed. Doing so would allow two classes to #include each other. See post for more info. --RavenSlayer 13:14, 3 March 2006 (EST)