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

Why are we switching naming conventions?

I am going through the Learn Java series so that I can get on to Android development. In the Java Objects the instructor made a big deal about sticking with the this.variable because that's more proper and professional looking and best practice. Now, we are immediately changing it. Is there are reason? And why so soon?

I believe that it did in the previous section. I just figured they would have saved it for the Android portion of the lessons and kept some sort of continuity while still studying Java.

In the last section he even brings out the Yoda character and talks about fear leading to anger in regards to using mVariable instead of wrestling and overcoming the initial awkwardness of this.variable.

Either way, I guess it's all good in the neighborhood. Thanks for responding.

Craig Dennis
Craig Dennis
Treehouse Teacher

Hi Darin!

Yeah if you are talking about the Java Data Structures it is because we originally were coding to the suggested Android style in the lessons. The Java Objects course was recently refreshed, but Data Structures course is still using the Android Open Source Guidelines.

Hoping to get that course refreshed here soon, and we will do away with the m prefix. Thanks for asking!

2 Answers

Hello mate,

I wasn't satisfied with my initial response so pulled it together in a oner.

I think Craig Dennis' early switch between conventions serves two purposes:

  1. To make students aware of the fact that multiple style conventions exist, and that adopting one over others is determined not only by what language you're coding with but also the organization or project you're coding for. For instance, Oracle's Code Conventions for the Java Programming Language lay down the foundational style rules to be adhered to when coding with the Java programming language; but the Android Open Source Project makes additions to these rules with its own Style Rules for Contributors, effectively creating a new set of conventions to adopt when specifically coding for Android.
  2. To illustrate that, regardless of which style conventions are adopted, they all serve the same purpose: they improve readability and reduce ambiguity amongst the audience adopting them, making it easier for changing contributors to maintain code over time.

Hope this helps

Thanks for all the responses. I appreciate the time taken to write well though out answers. Cheers!