-
Notifications
You must be signed in to change notification settings - Fork 9
feat(dev-docs): Require the measurement unit in names if it is not in the static type. #65
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,9 +2,28 @@ | |||||||||||
|
|
||||||||||||
| Follow the guidelines below when writing and updating any source files. | ||||||||||||
|
|
||||||||||||
| ## Naming | ||||||||||||
|
|
||||||||||||
| ### Measurement units | ||||||||||||
|
|
||||||||||||
| When handling data with measurement units, the unit must always be explicitly stated. | ||||||||||||
| If the unit is not statically available in the type information, then it must be added to the name, | ||||||||||||
| preferably as a suffix. | ||||||||||||
|
|
||||||||||||
| For example, in C++ when storing a measure of kibibytes inside an integer type, name the variable | ||||||||||||
| with a `_kib` suffix (e.g. `encoded_size_kib`). | ||||||||||||
|
|
||||||||||||
| It is not a requirement to use abbreviations, as the goal is clarity. For example, when measuring | ||||||||||||
| milliseconds adding `_ms` is actually ambiguous as to whether it's milli or mega, so we use | ||||||||||||
| `_millisecs` (e.g. `parsing_time_millisecs`). | ||||||||||||
|
Comment on lines
+16
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win Prefer a clearer unit suffix in the example. This example still relies on a fairly terse abbreviation, which weakens the “clarity” rule you just introduced. Consider spelling out the unit in the sample identifier so the guidance is self-explanatory. Proposed wording-For example, when measuring milliseconds adding `_ms` is actually ambiguous as to whether it's milli or mega, so we use `_millisecs` (e.g. `parsing_time_millisecs`).
+For example, when measuring milliseconds, use a `_milliseconds` suffix (e.g. `parsing_time_milliseconds`).📝 Committable suggestion
Suggested change
🧰 Tools🪛 LanguageTool[style] ~17-~17: Consider shortening this phrase to just “whether”, or rephrase the sentence to avoid “as to”. (WHETHER) 🤖 Prompt for AI Agents
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kirkrodrigues I'm guessing there is a better word for "clarity" here that also address the rabbit's concern (I don't fully agree with it, but I see its point). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Option 1 directly ties the rule to the actual problem being illustrated (the |
||||||||||||
|
|
||||||||||||
| Using `std::chrono` in C++ is an example of when the type (and API) explicitly handles the unit and | ||||||||||||
| it is unnecessary to add a suffix. | ||||||||||||
|
|
||||||||||||
| ## Code organization | ||||||||||||
|
|
||||||||||||
| (declaration-order)= | ||||||||||||
|
|
||||||||||||
| ### Declaration order | ||||||||||||
|
|
||||||||||||
| Organize declarations in order of: | ||||||||||||
|
|
||||||||||||
Uh oh!
There was an error while loading. Please reload this page.