6 ms·
I know I'm in the minority in the Java world, but I prefer prefacing member variables in Java with m_. I know there are myriad arguments about the editors bein
by nicpottier 15y ago
I know I'm in the minority in the Java world, but I prefer prefacing member variables in Java with m_.
I know there are myriad arguments about the editors being smart enough now to keep you from making the foo = foo instead of this.foo = foo mistake, but I just grew up on it and I like the clear obvious separation of 'that variable is a member variable' that m_ provides.
The rest of Hungarian notation though, never used it.
Oh and save the flames on m_, I've debated it to death, you aren't going to change my mind now. :)
- mberning 15y agoI agree with you that the notation can be helpful. My problem, at least in the java world, is that prefixing is inconsistent across the board. Even within the same file you will find mixed notation. I have to say that I have enjoyed ruby's variable conventions which are enforced by the language and seem to be much less abused.
- nicpottier 15y agoNo, agreed, and is my one reservation on continuing to use m_ in the Java world since there is such a huge body of code that has decided not to. (this was less of an issue 15 years ago when I started) If I'm working on an existing body of work I take on whatever convention is used of course. As for mixed in a file, there's just no excuse for that. If you are the kind of religious zealot that thinks her rightness in bracketing style or naming convention is so superior that it should override the convention used in a file then you have no business coding on a team.
- tszming 15y agoAndroid developers use the m prefix as well, so it is not minority: http://www.mail-archive.com/android-developers@googlegroups.com/msg81111.html http://www.mail-archive.com/android-developers@googlegroups.... Although I don't agree with them :)
- dhimes 15y agoIf I tag variables, it's usually as a suffix rather than a prefix. It just feels better to me that way. Two related variables can show up alphabetically near each other that way where the suffix tells them apart (often with a _ separating them: uname_clean).
- njharman 15y agoSame except the Java parts. Is why I hugely love Python's self.
- InclinedPlane 15y agoFor me anyway if I have so many member variables in a class or local variables in a method that it becomes a challenge to keep them straight then I will take that as an indication to refactor.