9

What does the "m" mean when it is put as a prefix before a word in android programming particularly in android java class files? I have lately been seeing it a lot in my generated main activity. Where can you use "m" as a prefix for statements/terms in programming? Like in the examples below:

mUserLearnedDrawer
mCurrentSelectedPosition
mFromSavedInstanceState
mUserLearnedDrawer
Alexis C.
  • 91,686
  • 21
  • 171
  • 177
  • 1
    It's a convention to have a distinction between member variables of a class and parameters (like in a constructor) – Alexis C. Mar 07 '15 at 13:35
  • 1
    Its for people who do not have a powerful integrated development environment that automatically displays member variables in a different color. To compensate for not having a different color, they use a different name. – Jack Mar 07 '15 at 13:38
  • 1
    Too bad this has been closed. Anyway, this style is called http://en.wikipedia.org/wiki/Hungarian_notation It was useful in earlier times; but in the year 2015, with IDEs that now anything about your source code, it should be avoided if possible. – GhostCat Mar 07 '15 at 13:42
  • @EddyG why should it be avoided ? – Blackbelt Mar 07 '15 at 13:43
  • @EddyG why should it be avoided? Google uses it alot. `GoogleApiClient mGoogleApiClient;`, with buttons, etc – Ojonugwa Jude Ochalifu Mar 07 '15 at 13:45
  • 2
    It is a matter of personal taste. Without an IDE, it was sometimes really hard to figure (easily) where a variable is coming from. Nowadays, all decent IDEs provide such information directly. In that sense - information that is not required can be seen as WASTE; and therefore it is fair to discuss avoiding it. I have been using such notation for 10+ years plus; and we decided to not do it in our new project - and I don't miss it at all. Because the IDE can tell me anything I need to know. And googles coding standard is googles coding standard; not mine. – GhostCat Mar 07 '15 at 13:54

2 Answers2

11

Letter m as prefix means that it is member of class. Letters lv means that it is local variable. Letters pm means that it is parameter.

example:

class Example
{
  Integer mMemberOfClass;

  public void someMethod(Object pmSomeParameter)
  {
    Integer lvSomeLocalVariable;

  }

}
Piotr Zych
  • 483
  • 4
  • 19
4

Simply it means this variable is member of the class.

Ajay S
  • 48,003
  • 27
  • 91
  • 111