public
(or, sometimes, the package-private) methods at the top,
and the private
methods at the bottom
public
methods are trivially short, by call-forwarding to corresponding private
methods
that do the actual work
When you see a class for the first time, then you usually want to know only one thing: what it can do for the caller.
If you follow the style suggested here, then all of that information appears at the top of the file, and,
just as important, only that information appears at the top.
All of the implementation details are placed at the bottom, in the private
methods.
Example
Note how the class is top-heavy with documentation.
import java.time.LocalDate; import java.time.LocalDateTime; /** Demo of short implementations for all public (or package-private) methods. Simply call-forward to similarly named private methods to do the actual work. */ public final class Astronomy { /** Find the eclipses that will occur at the given position on the Earth, between the two given dates (UTC). Both lunar and solar eclipses are returned. @param position location for which the eclipses are desired @param from the start-date (inclusive, UTC). @param to the end-date (inclusive, UTC). */ public Ephemeris eclipses(Position position, LocalDate from, LocalDate to){ return eclipsesCalc(position, from, to); } /** Return an ephemeris for the Moon, for the given date-time (UTC). @param position can be null; if not null, then topocentric elements are also included in the returned ephemeris. */ public Ephemeris moon(LocalDateTime utc, Position position){ return moonCalc(utc); } /** Return an ephemeris for the Sun, for the given date-time (UTC). */ public Ephemeris sun(LocalDateTime utc){ return sunCalc(utc); } /** A struct to carry data related to the position of a celestial object. */ public static final class Ephemeris { //.. elided } /** A struct to carry data related to the position on the surface of the Earth. */ public static final class Position { //.. elided } //..elided // PRIVATE private Ephemeris eclipsesCalc(Position position, LocalDate from, LocalDate to){ Ephemeris result = new Ephemeris(); /* * * * elided: long implementation * * */ return result; } private Ephemeris moonCalc(LocalDateTime to){ Ephemeris result = new Ephemeris(); /* * * * * elided: long implementation * * * */ return result; } private Ephemeris sunCalc(LocalDateTime to){ Ephemeris result = new Ephemeris(); /* * * * * elided: long implementation * * * */ return result; } }