Why do most fields (class members) in Android tutorial start with `m`?

pambuk picture pambuk · Jan 19, 2010 · Viewed 85.2k times · Source

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?

Answer

xiaobing.zhao picture xiaobing.zhao · Aug 16, 2011

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.