#311 Check for order of methods

Check (274)

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
good idea.

Here is what
has to say on the subject: 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
private fields
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.


  • Roman Ivanov

    Roman Ivanov - 2015-10-22
    • status: open --> closed
    • Group: --> Future

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks