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 - Retired Getting There Class Review

Allow us to use "this" instead of mvariable. Its not wrong. Just another way of doing it.

Allow us to use this statement instead of mvariable. Its not wrong. Just another way of doing it.

package com.example; import java.util.Date;

public class BlogPost {

private String mAuthor, mTitle, mBody, mCategory; private Date mCreationDate;

}

2 Answers

Emmanuel C
Emmanuel C
10,636 Points

You're right, that way is not wrong, but following convention is very important. Especially in professional development where you're going to have to read and edit other people's code and they will have to read and edit your code. A lot of time is wasted trying to figure out the use or values of certain variable inside of huge vaguely named methods other programmers have written, when proper naming conventions could have made the code neater and easier to read.

Thank you for your response as I understand in the corporate environment each boss will vary. I always forget that the course I am is in is beginner, and I am taking it just to refresh my brain.

Hi Neiko. I agree, there are 2 ways of naming field variables. However, bear in mind that this is a teaching environment and as such, Treehouse is just showing us both ways so we know how to use the 2 of them. In this exercise, you have to use the m-notation I'm afraid. Just take it as a practice exercise. You might have a boss or a team in the future who will ask you to do the same :)

On a side note, in your code, remember that creationDate is not a String but a Date. Happy coding :)

I have edited my code for others to see. Thank you for responding and explaining the differences!

No problem. I see you said you're not a beginner. I understand some exercises can be frustrating as you have to do them a certain way and you might be used to a different or even easier one. Just do as you're told :) That being said, I'm refreshing my skills too, and I find that I've learned quite a few things along the way as it's forced me to tackle things differently at times.