I think it's good style to declare methods in a class
in a standard order.
But I don't think checkStyle currently supports that.
If this isn't currently being worked on, I might try
implementing the check myself if others think it's a
Here is what
has to say on the subject:
22.214.171.124 Ordering Member Functions and Fields
One way to make your classes easier to understand is to
declare them in a consistent manner. The common
approach in Java is to declare a class in the order of
most visible to least visible (NPS, 1996), enabling you to
discover the most important features, the public ones,
first. Laffra (1997) points out that constructors and
finalize() should be listed first, presumably because
these are the first member functions that another
developer will look at first to understand how to use
the class. Furthermore, because we have a standard to
declare all fields as private, the declaration order
really boils down to:
public member functions
protected member functions
private member functions
Within each grouping of member functions it is common
to list them in alphabetical order. Many developers
choose to list the static member functions within each
grouping first, followed by instance member
functions, and then within each of these two
sub-groupings list the member functions alphabetically.
of these approaches are valid, you just need to choose
one and stick to it.
Log in to post a comment.