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
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 »

^

GAYGAYGAYGAYGAYG
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 »

I generally only leave the curly brace on the same line when I'm defining a single class in a header file. Anywhere else I move it to the next line just because it makes it much easier to find them. Every now and then I switch between habits for curly braces, but my naming conventions have stayed pretty firm.
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 recently started keeping my curly things on the same line... IDK why though... oh well... I like it better
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 »

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

Anyway, I will say that the style that Kendall and I have adopted 100% matches Innerscope:
Member functions StartWithCapitalLetter in the engine now, and members start with m? Aw, I dislike both of those. Guess it's a good thing I'm not programming the engine :P
Although I do occasionally see where it would be beneficial to name members with an m.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
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 »

MarauderIIC wrote:
GyroVorbis wrote::shock: I have no idea how that happened...

Anyway, I will say that the style that Kendall and I have adopted 100% matches Innerscope:
Member functions StartWithCapitalLetter in the engine now, and members start with m? Aw, I dislike both of those. Guess it's a good thing I'm not programming the engine :P
Although I do occasionally see where it would be beneficial to name members with an m.
Oh, actually. I didn't notice that. Maybe not 100%. We don't do mData for members. That does annoy me too.

We did start capitalizing non accessor member functions now like:
object.getMember();
object.setMember();
object.Load();
object.Save();
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 »

GyroVorbis wrote:
MarauderIIC wrote:
GyroVorbis wrote::shock: I have no idea how that happened...

Anyway, I will say that the style that Kendall and I have adopted 100% matches Innerscope:
Member functions StartWithCapitalLetter in the engine now, and members start with m? Aw, I dislike both of those. Guess it's a good thing I'm not programming the engine :P
Although I do occasionally see where it would be beneficial to name members with an m.
Oh, actually. I didn't notice that. Maybe not 100%. We don't do mData for members. That does annoy me too.
I tend to do this for organization sake. I will occasionally use a data type identifier for local variables (i.e. Vector vPosition) if the function is complicated. I hear that's looked down upon here as well. :lol:
Current Project: Gridbug
Website (under construction) : http://www.timcool.me
User avatar
Bludklok
Chaos Rift Junior
Chaos Rift Junior
Posts: 241
Joined: Tue Apr 14, 2009 1:31 am
Current Project: EnigmaCore
Favorite Gaming Platforms: PC, N64, Playstation1, Playstation2
Programming Language of Choice: C++
Location: New Jersey
Contact:

Re: Style Guide

Post by Bludklok »

Ill show you my style in a simple DoS calculator program...

Code: Select all

#include <iostream>
#include <windows.h>
using namespace std;
int main(){int a,b;a=b=0;cout<<"Input first var: ";cin>>a;cout<<endl;cout<<"Input second var:  ";cin>>b;cout<<endl;cout<<a<<" + "<<b<<" = "<<a+b;cout<<endl;system("pause");return 0;}
For the record, a total of 7 brain tumors, a broken leg, a fractured spine, and an I.Q. reduction of about 95% was suffered in the making of this program. I can feel my brain bleeding. (One of my top priorities in a program is neatness and readability)

On a side note... Imagine debugging a program where the entire source code is on 1 line... "Error on line 3". :nono:
Youtube
Website
Current project: Enigma Core
User avatar
MadPumpkin
Chaos Rift Maniac
Chaos Rift Maniac
Posts: 484
Joined: Fri Feb 13, 2009 4:48 pm
Current Project: Octopia
Favorite Gaming Platforms: PS1-3, Genesis, Dreamcast, SNES, PC
Programming Language of Choice: C/++,Java,Py,LUA,XML
Location: C:\\United States of America\Utah\West Valley City\Neighborhood\House\Computer Desk

Re: Style Guide

Post by MadPumpkin »

dejai wrote:Do you have a standard set for how you indent your code to make it more manageable and readable?
what is... readable? and.... manageable?
readable code? what is that?
While Jesus equipped with angels, the Devil's equipped with cops
For God so loved the world that he blessed the thugs with rock
Image
Image
Image
User avatar
MadPumpkin
Chaos Rift Maniac
Chaos Rift Maniac
Posts: 484
Joined: Fri Feb 13, 2009 4:48 pm
Current Project: Octopia
Favorite Gaming Platforms: PS1-3, Genesis, Dreamcast, SNES, PC
Programming Language of Choice: C/++,Java,Py,LUA,XML
Location: C:\\United States of America\Utah\West Valley City\Neighborhood\House\Computer Desk

Re: Style Guide

Post by MadPumpkin »

M_D_K wrote: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;
     }
}
like wise, mine to
While Jesus equipped with angels, the Devil's equipped with cops
For God so loved the world that he blessed the thugs with rock
Image
Image
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 »

MadPumpkin wrote:
M_D_K wrote: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;
     }
}
like wise, mine to
Mar, I think we need a forum-wide ban on everybody who does their braces like:

Code: Select all

if(some bullshit) 
{

}
Because everybody knows that

Code: Select all

if(proper) {

}
is the proper practice!
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 »

RIGHT ON FALCO!!!!
Image
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 »

I'm going to switch just because Falco said that. Falco is my idol. He knows best. :mrgreen:
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
gordon
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 60
Joined: Mon May 04, 2009 2:38 pm

Re: Style Guide

Post by gordon »

I guess Falco doesn't get on well with the GNU coding guidelines then....

http://www.gnu.org/prep/standards/html_ ... tting.html

To be honest I prefer the following

Code: Select all

if(something){

}
but I can understand the need to put up with both depending on the project.
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 »

GyroVorbis wrote:
MadPumpkin wrote:
M_D_K wrote: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;
     }
}
like wise, mine to
Mar, I think we need a forum-wide ban on everybody who does their braces like:

Code: Select all

if(some bullshit) 
{

}
Because everybody knows that

Code: Select all

if(proper) {

}
is the proper practice!
You can try to ban me ;)
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.
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 »

M_D_K wrote:You can try to ban me ;)
Speaking from experience: I wouldn't say that if I were you.. :lol:
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
Post Reply