Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which field names get prefix 'm'?

The convention says: "Non-public, non-static field names start with m. Other fields start with a lower case letter". Does it refer to class field only (like in example 1) or to all field (like in example 2)?

Example 1

public class One {
   private int mFieldOne;
   private int mFieldTwo;

   public void someMethod(){
      int methodFieldOne;
      int methodFieldTwo;
   }
}

Example 2

public class Two {
   private int mFieldOne;
   private int mFieldTwo;

   public void someMethod(){
      int mMethodFieldOne; //see m here
      int mMethodFieldTwo; //see m here
   }
} 
like image 395
sandalone Avatar asked Feb 08 '12 16:02

sandalone


2 Answers

In your second example, mMethodFieldOne and mMethodFieldTwo are not fields, just variables local to someMethod, so the naming convention does not apply.

like image 134
Giulio Piancastelli Avatar answered Oct 15 '22 18:10

Giulio Piancastelli


It refers to fields only, which are the class members (= m). The others are local variables.

like image 32
Andreas Dolk Avatar answered Oct 15 '22 18:10

Andreas Dolk