Skip to content

Commit

Permalink
CONTRIBUTING.md update with some more best practices. (#2301)
Browse files Browse the repository at this point in the history
* add a section on class member ordering, since it's not covered in the google style guide

* add an item about toString methods

* add a note about final fields coming before non-final
  • Loading branch information
jkwatson authored Dec 16, 2020
1 parent dbb1ae9 commit 76e10c5
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ which uses [google-java-format](https://github.com/google/google-java-format) li
* By default, all arguments/members are treated as non-null. Every argument/member that can be `null` must be annotated with `@Nullable`.
* 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
* 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.

If you notice any practice being applied in the project consistently that isn't listed here, please consider a pull request to add it.

Expand Down

0 comments on commit 76e10c5

Please sign in to comment.