views:

231

answers:

3

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? ;)

+8  A: 

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.

Kolky
+3  A: 

If it's member variables in classes, the 'm' means 'member'. Many Java programmers do that, although with modern IDEs it's not needed since you have highlighting, mouse over tooltips, etc.

ahans
I would argue that even with a modern IDE it's nice to prefix members with m or m_ for the purpose of bringing up all member variables for a class in the same place when using code completion.This means that when you're working in a class you can just hit m_ + ctrl space to get a list of all members.
Nailer
Agreed, I usually also prefix members with 'm' in Java. I added that last sentence to show that this is nothing all Java programmers agree on. Sun's coding style for instance doesn't include the 'm' prefix.
ahans
Nailer, you could achieve the same by using this. + ctrl space :)
Romain Guy
+1  A: 

I think it is very individual which code conventions is used. I prefer to name my variables with the following prefixes:

  • m - Method variables
  • c - Class variables
  • p - Parameter variables

But I guess that each programmer has his own style :-)

Steffen Jørgensen