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! While you're at it, check out some resources Treehouse students have shared here.

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

Java Java Data Structures Getting There Class Review

David Reese
David Reese
3,515 Points

How come he names the variables mAuthor, mDescription, mCreationDate instead of just using this.author = author?

How come he names the variables mAuthor, mDescription, mCreationDate instead of just using this.author = author in the constructor?

3 Answers

Karen Fletcher
Karen Fletcher
19,189 Points

Not sure the teacher's specific reason for why, but they're using Hungarian notation which is a common naming convention for member variables in Java and Android.

Watching the video again, the m prefix seems to be used to aid us learners/the user of the code in distinguishing that the declared variables are member variables, and so are different to the information being passed in by the user for that instance of the class.

So in the case of: mAuthor = author; It is clear which is the member variable (left) and which is the information passed into the constructor (right)

Other than that I remember Craig saying in an earlier course that it is a matter of style, and that the m prefix is commonly used in Android programming.