Best naming techniques/conventions to use?
Moderator: Coders of Rage
- Bullet Pulse
- Chaos Rift Cool Newbie
- Posts: 89
- Joined: Sun Feb 21, 2010 6:25 pm
Best naming techniques/conventions to use?
I was just wondering what the "best" naming conventions are for programming in general.
For example, some books say to prefix static data members with s_.
For example, some books say to prefix static data members with s_.
-
- Chaos Rift Junior
- Posts: 345
- Joined: Tue Jan 12, 2010 7:23 pm
- Favorite Gaming Platforms: PC - Windows 7
- Programming Language of Choice: c++;haxe
- Contact:
Re: Best naming techniques/conventions to use?
There is no "best" one per-say. The "best" one is to choose one that is easy to read and follow, and that you stick to. There are more ways out there then what you could realise, so google is your best bet to find one you like.
Peronally I find what works best for me so far is that all data members are lower case, all functions and classes, etc are uppercase starting, as well as function arguments. If there's another word in said symbol, then I also capitalise the start. It's a fast, efficient way of doing things. It's worked well for me in the past with other languages and so far it seems to hold up well in c++ as well.
ie
You can quite easily overdo it on the naming conventions, and slow down your flow. The time it takes to keep your chosen convention in check goes up conventionally with how complex it is. . I *hate* underscores for this very reason. Any good IDE will tell you what the value type is anyway (pointer, static, etc).
Atleast, that's my reasoning.
edit: 100th post w00t!
Peronally I find what works best for me so far is that all data members are lower case, all functions and classes, etc are uppercase starting, as well as function arguments. If there's another word in said symbol, then I also capitalise the start. It's a fast, efficient way of doing things. It's worked well for me in the past with other languages and so far it seems to hold up well in c++ as well.
ie
Code: Select all
namespace Nothing {}
ClassFunction(type ArgumentOne);
classMember;
...
Atleast, that's my reasoning.
edit: 100th post w00t!
-
- Chaos Rift Regular
- Posts: 173
- Joined: Thu Feb 11, 2010 9:46 pm
Re: Best naming techniques/conventions to use?
It doesen't matter as long as you stick with it for the entire project. If you decide to work on team projects your going to have to learn to adapt to different conventions to keep things consistent between team members anyway. With that said, there's certain language dependent naming conventions that should probably be avoided to prevent conflict (an underscore followed by capital letter or double underscores used to prefix an identifier in C++).
-
- Chaos Rift Newbie
- Posts: 9
- Joined: Thu Jan 28, 2010 3:24 pm
Re: Best naming techniques/conventions to use?
I like to name everything LikeThis except for local and private variables which I name likeThis.
- dandymcgee
- 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: Best naming techniques/conventions to use?
Same. With the exception of constants which are LIKETHIS.nardi11011 wrote:I like to name everything LikeThis except for local and private variables which I name likeThis.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!
-
- Chaos Rift Junior
- Posts: 345
- Joined: Tue Jan 12, 2010 7:23 pm
- Favorite Gaming Platforms: PC - Windows 7
- Programming Language of Choice: c++;haxe
- Contact:
Re: Best naming techniques/conventions to use?
If it's in c++, it's generally a BAD idea to do that, as then you risk conflicting with marco's/defines. Assuming all of them are uppercase :P.dandymcgee wrote:Same. With the exception of constants which are LIKETHIS.nardi11011 wrote:I like to name everything LikeThis except for local and private variables which I name likeThis.
- dandymcgee
- 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: Best naming techniques/conventions to use?
I suppose it's a matter of remembering not to name your constant the same name as your macro lol.Live-Dimension wrote:If it's in c++, it's generally a BAD idea to do that, as then you risk conflicting with marco's/defines. Assuming all of them are uppercase :P.dandymcgee wrote:Same. With the exception of constants which are LIKETHIS.nardi11011 wrote:I like to name everything LikeThis except for local and private variables which I name likeThis.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!
- MrDeathNote
- ES Beta Backer
- Posts: 594
- Joined: Sun Oct 11, 2009 9:57 am
- Current Project: cocos2d-x project
- Favorite Gaming Platforms: SNES, Sega Megadrive, XBox 360
- Programming Language of Choice: C/++
- Location: Belfast, Ireland
- Contact:
Re: Best naming techniques/conventions to use?
Dittodandymcgee wrote:Same. With the exception of constants which are LIKETHIS.nardi11011 wrote:I like to name everything LikeThis except for local and private variables which I name likeThis.
http://www.youtube.com/user/MrDeathNote1988
"C makes it easy to shoot yourself in the foot. C++ makes it
harder, but when you do, it blows away your whole leg." - Bjarne Stroustrup
"C makes it easy to shoot yourself in the foot. C++ makes it
harder, but when you do, it blows away your whole leg." - Bjarne Stroustrup
-
- Chaos Rift Junior
- Posts: 345
- Joined: Tue Jan 12, 2010 7:23 pm
- Favorite Gaming Platforms: PC - Windows 7
- Programming Language of Choice: c++;haxe
- Contact:
Re: Best naming techniques/conventions to use?
You should let the compiler deal with that, not try to "remember". You completely skip human memory error when you don't do this. plus, I may add some SDK later on and it may just have the exact same name for a definition, especially if its a C SDK and not C++.dandymcgee wrote:I suppose it's a matter of remembering not to name your constant the same name as your macro lol.Live-Dimension wrote:If it's in c++, it's generally a BAD idea to do that, as then you risk conflicting with marco's/defines. Assuming all of them are uppercase :P.dandymcgee wrote:Same. With the exception of constants which are LIKETHIS.nardi11011 wrote:I like to name everything LikeThis except for local and private variables which I name likeThis.