Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Objects (Retired) Creating the MVP Prompting for Guesses

Naming conventions

I am having trouble keeping everything straight because of the way things are named. As it stands right now, I can't remember what any of these things do because they are all named the same thing. For example:

public class Prompter { 
  private Game mGame;

  public Prompter(Game game) {
    mGame = game; 
  }

The word GAME is incorporated into the code six different times. Now it's all muddled and I have no idea what the code means anymore. Is the naming of things always like this or is it just to keep things simple for the course? My thinking is that it makes it more complicated until one gets to a point where the different classes and methods and variables make sense naturally.

1 Answer

Yeeka Yau
Yeeka Yau
7,410 Points

It definitely can be confusing, especially at the beginning. Just remember that the convention is that your object type starts with a capital letter, and an instance of that object uses the camel case notation.

For example in your Prompter constructor, you are passing in an object of type Game, and the instance of the object is called game (this can be confusing, and you can call the instance something else). For example, you could write it as:

public Prompter(Game hangmanGame){
mGame = hangmanGame;
}

Hope that helps.