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 Objects (Retired) Harnessing the Power of Objects Methods and Constants

Jerry Leppänen
Jerry Leppänen
998 Points

Any special order to list classes etc?

Still trying to grasp how classes and methods and everything really works, but I was thinking, is there a special order you "should" list everything when you are declaring classes and so on? If you know what I mean..

1 Answer

Alexander Nikiforov
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 Points

Check this nicest "Google Java Style Guide":

https://google.github.io/styleguide/javaguide.html

There are lot of nice stuff, and a long there you can find the following part

The ordering of the members of a class can have a great effect on learnability, but there is no single correct recipe for how to do it. Different classes may order their members differently.

What is important is that each class order its members in some logical order, which its maintainer could explain if asked. For example, new methods are not just habitually added to the end of the class, as that would yield "chronological by date added" ordering, which is not a logical ordering.

Taken from:

https://google.github.io/styleguide/javaguide.html#s3.4.2-class-member-ordering

Jerry Leppänen
Jerry Leppänen
998 Points

Thanks :)

Just what I was looking for!