Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
Parker Busswood20,207 Points
Using 'm' for member variable prefix
In the Teacher Notes, Craig mentions that he's prefixing the variable name with the letter 'm' because it's a member variable, and this is in line with the Android code style guidelines (http://source.android.com/source/code-style.html#follow-field-naming-conventions).
Following that link, the Android guidelines suggest that non-public, non-static field names start with the letter 'm', but the example in the video was 'public String mCharacterName = "Yoda";' which isn't a non-public field name. Hunting for further explanation on StackOverflow, it also appears that many people suggest not using that notation as modern IDEs can display different items (eg. member variables) in different colors to help uniquely identify them. I might be misinterpreting the Android guidelines; any clarification would be much appreciated!
First off - the member was public only temporarily, as Craig mentioned. Meaning we'll change it to private later.
Now about the naming, it all comes down to personal preferences. I usually dislike the "m" prefix and do not use it(therefore I do not know about when it is proper to use it and when not, since I always omit it). If you choose that method, you'll have to learn about the "this" keyword. It's nothing special, don't worry. Modern IDEs (as you refer to them) will add it when they generate code for you (setters for example)
I don't think you should worry about this issue a lot. Just pick a method and stick to it.