Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

An interesting detail about variable name

I have read tutorials all over the web with different kinds of tutorials specified on game (however, this turns out to be pretty general).

Are there any reasons to why many developers name their variables like:

mContext

For me it is default to just name it "context" or something similar.

Are there any reasons why the "m" are before? (I know that this is a matter of style, but I'm just curious what it stands for)

like image 326
Curtain Avatar asked Sep 02 '10 16:09

Curtain


2 Answers

To those of us who disapprove of cluttering up our variable names with such characters, they're known as "warts". In my opinion, with today's IDEs it is better to leave the warts off, because we can readily distinguish between local variables and member variables without their help.

like image 78
Carl Manaster Avatar answered Sep 24 '22 22:09

Carl Manaster


The m will be to signify that the object is a member variable of the class in question. It's a common use of Hungarian Notation to prefix the name with clues to the variable's purpose or type.

like image 28
DoctorRuss Avatar answered Sep 26 '22 22:09

DoctorRuss