Style Guide

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

User avatar
dejai
Chaos Rift Junior
Chaos Rift Junior
Posts: 207
Joined: Fri Apr 11, 2008 8:44 pm

Style Guide

Post by dejai »

Do you have a standard set for how you indent your code to make it more manageable and readable? I am specifically asking this question to the elysian shadows development team as I don't want to be flooded with every ones personal indentation. Nor do I want this to turn into an Emacs vs Vi war because we all know that Emacs is much better. Anyway thanks.
User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

Re: Style Guide

Post by eatcomics »

I think it's more of a personal thing, I bet they all do it the way their used to. Once you get one you like you stick with it...
Image
User avatar
dejai
Chaos Rift Junior
Chaos Rift Junior
Posts: 207
Joined: Fri Apr 11, 2008 8:44 pm

Re: Style Guide

Post by dejai »

Not if your working for someone.

OSI examples:
Linux (1TB)
BSD (Allman)
User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

Re: Style Guide

Post by eatcomics »

ahh, I stand corrected, but I bet the team does it the way I said... but I guess we'll find out :)
Image
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: Style Guide

Post by MarauderIIC »

dejai wrote:Do you have a standard set for how you indent your code to make it more manageable and readable? I am specifically asking this question to the elysian shadows development team as I don't want to be flooded with every ones personal indentation.
Yes. And naming conventions, too.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

Re: Style Guide

Post by eatcomics »

Darn, I'm just being wrong all over the place!!! :lol:
Image
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: Style Guide

Post by Falco Girgis »

Of course we god. You can't work in a team without that stuff.
User avatar
Innerscope
Chaos Rift Junior
Chaos Rift Junior
Posts: 200
Joined: Mon May 04, 2009 5:15 pm
Current Project: Gridbug
Favorite Gaming Platforms: NES, SNES
Programming Language of Choice: Obj-C, C++
Location: Emeryville, CA
Contact:

Re: Style Guide

Post by Innerscope »

Nor do I want this to turn into an Emacs vs Vi war because we all know that Emacs is much better.
...But Vim rules!!! :lol:, jk
You're writing C++ programs in emacs? What are you, a masochist?
I am specifically asking this question to the elysian shadows development team as I don't want to be flooded with every ones personal indentation.
That's too bad, because I'm going to tell you my style and indentation anyway

Code: Select all

class Sprite : public Object {

protected:
     type     protectedMember1;
     type     protectedMember2;

     type     protectedMember3; // no relation to 1 or 2

public:
     Sprite();
     ~Sprite();

     virtual void Render();

     void     SetMemberData(type nData) {protectedMember = nData;}
     void     SetMemberData(type nData);
     return type     GetMemberData() {return mData;}

};

//blocks of code
void Sprite::Render() {
     local variable declarations;
     render code;

     if(variable1 == variable2) {
          do code;
     }
}

/*
Naming conventions:
Class: Sprite -> Extended Class: GameSprite
Members: mImage, mPosition, mAnimIndex    
Functions: Move, SetSpriteSheet, StartAnimation 
*/
Definitely not all there is to show, but you get the basic idea...
If I were to work for someone else, it wouldn't be difficult for me to conform to their naming conventions/style though. I notice a lot of trained programmers are very similar (in indentation style) anyway.
Current Project: Gridbug
Website (under construction) : http://www.timcool.me
User avatar
thejahooli
Chaos Rift Junior
Chaos Rift Junior
Posts: 265
Joined: Fri Feb 20, 2009 7:45 pm
Location: London, England

Re: Style Guide

Post by thejahooli »

100th post for me :)

My naming convention is the same as most people from what I have seen.

Code: Select all

// Variables start with lowercase and each new word is captial
int playerPosition;
// Functions start with Capital and each new word is capital
void FunctionOne() { }
// Class name is same as a function name
class PlayerClass
{
};
// constants and enums values in all caps, enum name same as class
const int ACONST;
enum Animal { DOG, CAT, BIRD };
As for indentation I use the default that visual studio does.
Also curly brackets have nothing on their line and if, for, etc. statements allways have curly brackets even with a single line within them.
I'll make your software hardware.
User avatar
ismetteren
Chaos Rift Junior
Chaos Rift Junior
Posts: 276
Joined: Mon Jul 21, 2008 4:13 pm

Re: Style Guide

Post by ismetteren »

thejahooli wrote:100th post for me :)

My naming convention is the same as most people from what I have seen.
I see you use capital letters for functions, how manydoes that? (i dosent, unless i use C#, since visual studio is forcing it on me... or maybe im just too lazy to change it. But i does not use C# much anyway... :P)
Image ImageImage Image
User avatar
thejahooli
Chaos Rift Junior
Chaos Rift Junior
Posts: 265
Joined: Fri Feb 20, 2009 7:45 pm
Location: London, England

Re: Style Guide

Post by thejahooli »

ismetteren wrote:
thejahooli wrote:100th post for me :)

My naming convention is the same as most people from what I have seen.
I see you use capital letters for functions, how manydoes that? (i dosent, unless i use C#, since visual studio is forcing it on me... or maybe im just too lazy to change it. But i does not use C# much anyway... :P)
I can never remember seeing anyone who doesn't do this.

EDIT: Actually I have seen some people who switch what I do between variables and functions, but only a very small amount.
I'll make your software hardware.
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: Style Guide

Post by dandymcgee »

GyroVorbis wrote:Of course we god. You can't work in a team without that stuff.
What? :lol:
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

Re: Style Guide

Post by eatcomics »

I was wondering that myself... :lol: I think he just really sucks at spelling do
Image
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: Style Guide

Post by Falco Girgis »

:shock: I have no idea how that happened...

Anyway, I will say that the style that Kendall and I have adopted 100% matches Innerscope:
Innerscope wrote: That's too bad, because I'm going to tell you my style and indentation anyway

Code: Select all

class Sprite : public Object {

protected:
     type     protectedMember1;
     type     protectedMember2;

     type     protectedMember3; // no relation to 1 or 2

public:
     Sprite();
     ~Sprite();

     virtual void Render();

     void     SetMemberData(type nData) {protectedMember = nData;}
     void     SetMemberData(type nData);
     return type     GetMemberData() {return mData;}

};

//blocks of code
void Sprite::Render() {
     local variable declarations;
     render code;

     if(variable1 == variable2) {
          do code;
     }
}

/*
Naming conventions:
Class: Sprite -> Extended Class: GameSprite
Members: mImage, mPosition, mAnimIndex    
Functions: Move, SetSpriteSheet, StartAnimation 
*/
Definitely not all there is to show, but you get the basic idea...
If I were to work for someone else, it wouldn't be difficult for me to conform to their naming conventions/style though. I notice a lot of trained programmers are very similar (in indentation style) anyway.
User avatar
M_D_K
Chaos Rift Demigod
Chaos Rift Demigod
Posts: 1087
Joined: Tue Oct 28, 2008 10:33 am
Favorite Gaming Platforms: PC
Programming Language of Choice: C/++
Location: UK

Re: Style Guide

Post by M_D_K »

My indentation matches in Innerscope's. But my curly brace placement is different.

Code: Select all

class Sprite : public Object
{
protected:
     type     protectedMember1;
     type     protectedMember2;

     type     protectedMember3; // no relation to 1 or 2

public:
     Sprite();
     ~Sprite();

     virtual void Render();

     void     SetMemberData(type nData) {protectedMember = nData;}
     void     SetMemberData(type nData);
     return type     GetMemberData() {return mData;}

};

//blocks of code
void Sprite::Render()
{
     local variable declarations;
     render code;

     if(variable1 == variable2)//usually if it's only one call don't even bother with braces
     {
          do code;
     }
}
Gyro Sheen wrote:you pour their inventory onto my life
IRC wrote: <sparda> The routine had a stack overflow, sorry.
<sparda> Apparently the stack was full of shit.
Post Reply