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.

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.