Skip to content

Commit

Permalink
Minor changes to class member ordering (#3295)
Browse files Browse the repository at this point in the history
* Minor changes to class member ordering

* Remove exception for static factory methods
  • Loading branch information
trask authored Jun 11, 2021
1 parent 870f721 commit b212fce
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,16 @@ changes to the API (e.g., remove a public method) or to the ABI (e.g., change re
* The project aims to provide a consistent experience across all the public APIs. It is important to ensure consistency (same look and feel) across different public packages.
* Use `final` for public classes everywhere it is possible, this ensures that these classes cannot be extended when the API does not intend to offer that functionality.
* In general, we use the following ordering of class members:
* static fields (final before non-final)
* non-static fields (final before non-final)
* constructors
* static methods
* instance methods
* inner classes
* Static fields (final before non-final)
* Instance fields (final before non-final)
* Constructors
* In static utility classes (where all members are static), the private constructor
(used to prevent construction) should be ordered after methods instead of before methods.
* Methods
* If methods call each other, it's nice if the calling method is ordered (somewhere) above
the method that it calls. So, for one example, a private method would be ordered (somewhere) below
the non-private methods that use it.
* Nested classes
* Adding `toString()` overrides on classes is encouraged, but we only use `toString()` to provide debugging assistance. The implementations
of all `toString()` methods should be considered to be unstable unless explicitly documented otherwise.

Expand Down

0 comments on commit b212fce

Please sign in to comment.