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

Extend best-practice list: recommend using typed units instead of integer-based conversions #6

Open
qwwdfsad opened this issue Apr 11, 2023 · 0 comments

Comments

@qwwdfsad
Copy link
Contributor

qwwdfsad commented Apr 11, 2023

It would be nice to recommend using typed units of measurement whenever possible.

E.g. in our official libraries we gave up on API in the form of foo(timeMillis: Long) and foo(time: Long, unit: TimeUnit) -- it's unnecessarily verbose, unclear from the call site (esp. when callers do not follow the naming convention), and, most importantly, is error-prone (off-by-order-of-magnitude errors). AFAIR Google even used to have a JVMLS talk about that, but all I can find is this discussion.

The same applies to any "easily-convertible" units -- SI, durations, bytes (kilo-/mega-) etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant