Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add section to coding guidelines on Optional usage #6894

Merged
merged 4 commits into from
Oct 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/contributing/style-guideline.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,11 @@ plugins {
id("otel.nullaway-conventions")
}
```

## java.util.Optional usage

Following the reasoning from [Writing a Java library with better experience (slide 12)](https://speakerdeck.com/trustin/writing-a-java-library-with-better-experience?slide=12),
usage of `java.util.Optional` is kept at a minimum in this project.

It is ok to use `Optional` in places where it does not leak into public API signatures and where
performance is not critical.
Comment on lines +135 to +136
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
It is ok to use `Optional` in places where it does not leak into public API signatures and where
performance is not critical.
Use `Optional` where it does not leak into public API signatures and where
performance is not a critical aspect.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe It is acceptable to use? we don't exactly want to "recommend" it, only mention that it is "ok" (i.e. author's choice to use or not)