Why do most fields (class members) in Android tutorial start with `m`?
I know about camel case rules, but I'm confused with this m rule. What does it stand for? I'm a PHP developer. "We" use first letters of variables as indication of type, like 'b' for boolean, 'i' for integer and so on.
Is 'm' a Java thing? Does it stand for mobile? mixed?
This notation comes from AOSP (Android Open Source Project) Code Style Guidelines for Contributors:
Follow Field Naming Conventions
- Non-public, non-static field names start with m.
- Static field names start with s.
- Other fields start with a lower case letter.
- Public static final fields (constants) are ALL_CAPS_WITH_UNDERSCORES.
Note that the linked style guide is for code to be contributed to the Android Open Source Project.
It is not a style guide for the code of individual Android apps.
A lot of coding guide lines use m for 'members' of a class. So when you're programming you can see the difference between local and member variables.
What is m prefix?
m stands for member variable or data member. Use m prefix for non-public and non-static fields.
When to Use?
private String mCityName;
private float mTemperature;
When not to Use?
public static int mFirstNumber;
public static final String mDATABASE_NAME;
What I do?
Personally, I don't use it. It makes the code more complicated and chaos the readability. If you are still using Notepad for coding I have no words, but modern IDEs are capable of highlighting and coloring member and local variables or anything else.
Conclusion
Use? "Yes" or "No" is your personal choice.