I pretty often see the following naming convention used in Java code.
class SomeClass { private final String name; public SomeClass(final String name) { this.name = name; } }
It seems a little strange to me. First of all, if you accidentally miss a variable in the method signature, it will still compile ...
class SomeClass { private final String name; public SomeClass(final String nane) { this.name = name; } }
Compiles in order. The nane flag may be used as an unused variable, but the assignment (which just becomes an independent assignment) imperceptibly compiles.
I believe I want to use "m" for member variables as such ...
class SomeClass { private final String mName; public SomeClass(final String name) { mName = name; } }
It is shorter than this option, and detects a previously odd spelling error.
However, my colleague gave me all kinds of flash when I presented this as an agreement on our new project, stating that "we do not do this in java."
Just curious why?
source share