Skip to content

Commit e96e08c

Browse files
authored
feat(AIP-141): add naming guidance compound and/or inverse unit fields (#1524)
* Updates AIP-141 to detail guidance for compound and inverse units This includes a new subsection covering compound units, a new subsection covering inverse units, and some overall wording adjustments to clarify when plural form should be used for field names. * Update AIP-140 to reference AIP-141 for use of preposition "per" AIP-141 has been updated with more detailed guidance on the use of the preposition "per" in field names representing quantities, and this note should be updated to refer to that guidance. Note that the previous note guidance here may have suggested that an event-frequency field should be named like e.g. "failures_per_hour", while after this change it will point to guidance in AIP-141 that specifies the format as e.g. "failure_count_per_hour". This may be interpreted as a functional change.
1 parent 9919c7c commit e96e08c

2 files changed

Lines changed: 37 additions & 7 deletions

File tree

aip/general/0140.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,8 @@ This is particularly true regarding "with": a field named `book_with_publisher`
7777
likely indicates that the book resource may be improperly structured and worth
7878
redesigning.
7979

80-
**Note:** The word "per" is an exception to this rule, particularly in two
81-
cases. Often "per" is part of a unit (e.g. "miles per hour"), in which case the
82-
preposition must be present to accurately convey the unit. Additionally, "per"
83-
is often appropriate in reporting scenarios (e.g. "nodes per instance" or
84-
"failures per hour").
80+
**Note:** The word "per" is an exception to this rule. See [AIP-141][] for
81+
guidance in the case where "per" is used as part of a unit (e.g. "miles per hour").
8582

8683
### Abbreviations
8784

aip/general/0141.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ number of miles, number of nodes, etc.).
1616

1717
Quantities with a clear unit of measurement (such as bytes, miles, and so on)
1818
**must** include the unit of measurement as the suffix. When appropriate, units
19-
**should** use generally accepted abbreviations (for example, `distance_km`
20-
rather than `distance_kilometers`).
19+
**should** use generally accepted abbreviations, and abbreviations **should not**
20+
be pluralized (for example, `distance_km` rather than `distance_kilometers`).
2121

2222
```proto
2323
// A representation of a non-stop air route.
@@ -49,6 +49,36 @@ message Cluster {
4949
**Note:** Fields **must not** use unsigned integer types, because many
5050
programming languages and systems do not support them well.
5151

52+
### Compound units
53+
54+
Quantities with compound units of measurement **may** use separating underscores
55+
between units as needed for clarity. Unabbreviated units **must** be separated.
56+
Abbreviated units **should not** be separated unless otherwise ambiguous.
57+
Compound units **should** be in plural form, with all component units in
58+
singular form except for the final component unit, which should be in plural
59+
form unless abbreviated.
60+
61+
- `energy_kwh` (**not** `energy_kw_h`)
62+
- `energy_kw_fortnights` (**not** `energy_kwfortnight` or `energy_kw_fortnight`)
63+
64+
**Note:** Metric prefixes **must not** be separated from their base unit.
65+
66+
### Inverse units
67+
68+
Quantities with units of measurement that are or include inverse units
69+
**should** indicate all inverse units as a compound unit after a compound
70+
of any non-inverse units, separated by the word "per".
71+
The inverse compound unit **should** be in singular form.
72+
73+
- `speed_miles_per_hour` (**not** `speed_mph`)
74+
- `speed_meters_per_second` (**not** `speed_meters_per_seconds` or `speed_meter_per_second`)
75+
- `event_count_per_hour` (**not** `events_per_hour`, `event_counts_per_hour`, or `hourly_events`)
76+
- `price_per_kwh` (using [`google.type.Money`][money])
77+
78+
**Note:** This guidance does not apply in cases where generally accepted derived
79+
units with special names and symbols exist for inverse quantities. For example,
80+
the derived unit 'hertz' **should** be used when appropriate for reciprocal time.
81+
5282
### Specialized messages
5383

5484
It is sometimes useful to create a message that represents a particular
@@ -65,6 +95,9 @@ the suffix for the field name if it makes intuitive sense to do so.
6595

6696
## Changelog
6797

98+
- **2025-07-09**: Added guidance for compound units.
99+
- **2025-07-09**: Clarified guidance to not pluralize abbreviated units.
100+
- **2025-07-09**: Clarified guidance to use per_ prefix to represent inverse units.
68101
- **2019-09-13**: Added the prohibition on uint and fixed types.
69102

70103
<!-- prettier-ignore-start -->

0 commit comments

Comments
 (0)