DBY
Who's Online
0 registered (), 10 Guests and 5 Spiders online.
Key: Admin, Global Mod, Mod
Latest Photo Gallery
light pole in the water
Eastern State Penitentiary - Philadelphia
Top Posters (30 Days)
HarryB 14
Anartist 12
FinalDJ 10
Goofy 9
m2h 7
Fitzy 3
Meph 2
Doorslammer 1
Nightowl 1
Dough 1
Topic Options
#170069 - 10/14/09 04:18 PM Common programming styles
diddy02 Offline
digital ghoul

Registered: 09/24/01
Posts: 6379
Loc: Lost forever...
Hey all...

quick question. I have to sort through someone else's C++ code and make some changes to it. He's initialized a significant amount of variables with the following format:

mVariableName

I can't figure out what the 'm' is for. The variables (to me anyway) look totally normal. Can any of you programmers offer insight on what the 'm' could be? I think I've seen the convention somewhere before as well, which leads me to believe it's not just a one-time thing.
_________________________
Fate is just a bullsh*t excuse for failure.

Top
#170078 - 10/14/09 06:47 PM Re: Common programming styles [Re: diddy02]
Mr_Blog Offline
human

Registered: 06/06/01
Posts: 13762
Loc: ${PWD}
could be a way to prevent collisions with his other apps and shared libraries?
_________________________
( o_
/ >) My 84-year-old non-techy mom uses Debian Linux. It ain't that hard.

Top
#170081 - 10/14/09 09:29 PM Re: Common programming styles [Re: Mr_Blog]
diddy02 Offline
digital ghoul

Registered: 09/24/01
Posts: 6379
Loc: Lost forever...
I found an interesting article on this. I'm going to link it for reference and in case anyone is interested:

[url=hxxp://igloocoder.com/archive/2006/07/08/405.aspx]hxxp://igloocoder.com/archive/2006/07/08/405.aspx[/url]

tldr;

//common ways of naming class variables
mVariableName
m_variableName
_variableName

The article is a good (short) read!
_________________________
Fate is just a bullsh*t excuse for failure.

Top
#170092 - 10/15/09 04:23 AM Re: Common programming styles [Re: diddy02]
scootermcfly Offline
Plunderer

Registered: 10/27/01
Posts: 442
Loc: NY
Like you found, the m prefix is usually for class level or module level variables.

Scooter McFly

Top
#170236 - 10/17/09 02:52 PM Re: Common programming styles [Re: scootermcfly]
DeionG Offline
Dread Pirate

Registered: 10/12/01
Posts: 2712
Loc: az/tx
what we use it is for m = member which means its a member of that class anyone in that class can use it. so it would be a member variable.


Edited by DeionG (10/17/09 02:53 PM)
_________________________

Top
#170243 - 10/17/09 07:44 PM Re: Common programming styles [Re: DeionG]
WeerDo Offline
King of the Ewoks

Registered: 06/10/01
Posts: 3921
Loc: New York City
seriously though, it could be anything...

you can make assumptions about the code based on common coding practices, but in reality, a developer could name the variable whatever the hell he felt like on that day.

theres no rhyme or reason that says you need to name things [this] way or else the variable won't initialize properly.

and honestly, you'd probably be better off taking this position if you're charged with reverse engineering or refactoring the code. its just ridiculously illogical to look at a line of code and say to yourself... "oh, this starts with a "S", it MUST be a string"

Top



Moderator:  Doorslammer, Nightowl, NightShade, Rez 
Shout Box

Today's Birthdays
No Birthdays
May
Su M Tu W Th F Sa
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31