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

Android Build an Interactive Story App (Retired) The Model-View-Controller Pattern Implementing the Data Model

Why is it important that all of the getter and setter methods not include the "m" in their names?

Isnt the naming of the titles of methods just up to the programmers preference?

1 Answer

One of the objectives in writing code is readability. If our code is easy to read then it will be easier to maintain and understand. Let's say I have a class called Circle and I have a property called color. My class may look like this:

public class Color {
   private String mColor;

}

Now if I wanted to create a setter/getter method for this variable, what do you think looks better:

getColor() or getmColor()?

I prefer the first because it is easier to read and understand. Ultimately it will be up to you to decide what makes your code look cleaner.