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?
The m is here to indicate a member variable. It has 2 huge advantages: If you see it, you instantly recognize it as a member variable.
Member variables in a class—these are called fields. Variables in a method or block of code—these are called local variables. Variables in method declarations—these are called parameters.
In Android Studio, highlight the method and either right click > Find usages or use the Alt + F7 shortcut.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With