0

Why everyone write variable starts with m? Adapter mApapter? But Android studio suggest Adapter adapter .
what is the good coding practice?which one is very clear to read.
what is use the universal name convention? I saw something like that on php.Adapter pAdapter.

JafarKhQ
  • 8,676
  • 3
  • 35
  • 45
Asthme
  • 5,163
  • 6
  • 47
  • 65

3 Answers3

0

'm' means member of the class. So, if you don't use IDE to highlight your members, then you will understand that it is a member by it's name.

Somtimes people use other prefixes if you discover some variables starting with 'i' or 's' it could also be a variant of the Hungarian Notation

For more info see Why do variable names often start with the letter 'm'?

In Android Coding Style Field Naming Conventions are

  • 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.

For more info see Android Follow Field Naming Conventions

Community
  • 1
  • 1
Giru Bhai
  • 14,370
  • 5
  • 46
  • 74
0

By taking a look at the Android code-style page you can see that:

  • 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.

https://source.android.com/source/code-style.html#follow-field-naming-conventions

simonevertsson
  • 111
  • 1
  • 5
0

Those are naming conventions for the AOSP project, and as many conventions, are a matter of religion more than reason. Those were not recommended neither in the Java Naming Conventions nor in Google´s Java Style Conventions.

In practice each organization or project has it own conventions.

I'd name it "adapter" for instance.

Mister Smith
  • 27,417
  • 21
  • 110
  • 193