Search code examples
javacoding-style

Is there a standard in java for _ (underscore) in front of variable or class names?


I have seen some programmers using _ (underscore) in front of class names, and others using it for local variables.

Does the Java standard require/suggest the use of _ (underscore) in front of an private instance variable or class name?


Solution

  • It is a matter of personal taste.

    Martin Fowler appears to like it. I don't care much for it - it breaks the reading pattern, and the information it conveys is already subtly told by color in your IDE.

    I've experimented with using _ as the name of the variable holding the result to be returned by a method. It is very concise, but I've ended up thinking that the name result is better.

    So, get your colleagues to agree on what you all like the most and then just do that.