Jump to content

Variable Standards

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
5 replies to this topic

#1
Saint

Saint

    Learning Programmer

  • Members
  • PipPipPip
  • 63 posts
I'm working on creating a set of "defined" rules for how I will develop in the future. I'm confused about how I should name variables in a consistent way that can appear in all of programs. My question is, what do you guys use?

Globals: __<name>

The what? Is camelCase used most often for everything else? What about objects?
Hi >> Saint

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
There are a number of standards out there. At work we use a simplified version of hungarian, at home I prefer camelCase. There are several books on programming standards that will address this issue quite thoroughly and can be gotten fairly cheap. I'll try to get the name of my book this weekend.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
The Elements of C++ Style
There's also
The Elements of C# Style
The Elements of Java Style
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#4
v0id

v0id

    Retired

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,936 posts
I've always used camelCase, but I'm thinking about changing to Hungarian Notation. Hungarian notation is almost like camelCase, excepts Hungarian Notation includes the type of the variable in its name.

CamelCase - Wikipedia, the free encyclopedia
Hungarian notation - Wikipedia, the free encyclopedia

#5
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Hungarian can be useful, but it can also get REALLY nuts. I think a limited version is useful.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#6
v0id

v0id

    Retired

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,936 posts

WingetPanther said:

Hungarian can be useful, but it can also get REALLY nuts. I think a limited version is useful.
You're right. Over the time I've seen some really long variable names, because of the use of Hungarian notation.

I'll probably only using them with variables/objects like integers, classes, booleans, etc.
int   iItems;
class CControl;
bool  bStatus;

// ...
That's enough for me.