Skip to content

Commit 58ec02b

Browse files
Protocol Buffer TeamLogofile
authored andcommitted
This change includes the following:
* Fixes spelling issue in Kotlin tutorial * Removes the Common Types section from the overview topic (which is a duplicate of the section by the same name in the Protobuf Best Practices topic) * Updates the organization of the Protouf Best Practices topic * Softens some language in the Proto2 Language Guide * Removes the Recommended Downcast Method topic from the public docs, since it applies only internally * Removes some Proto1 content from the Java Proto Names topic, as well as adding some clarifying information to the other sections PiperOrigin-RevId: 578258372 Change-Id: Ic318d1491b8270c09f2a465a9010fd95e94038aa
1 parent a16fab4 commit 58ec02b

File tree

6 files changed

+55
-261
lines changed

6 files changed

+55
-261
lines changed

content/getting-started/kotlintutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ existing APIs generated for protocol buffers for Java. This ensures that
199199
codebases written in a mix of Java and Kotlin can interact with the same
200200
protocol buffer message objects without any special handling or conversion.
201201

202-
Protocol buffers for other Kotlin compilation targets, such as Javascript and
202+
Protocol buffers for other Kotlin compilation targets, such as JavaScript and
203203
native, are not currently supported.
204204

205205
Compiling `addressbook.proto` gives you the following APIs in Java:

content/overview.md

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -278,36 +278,8 @@ Protocol buffers support many scalar value types, including integers that use
278278
both variable-length encoding and fixed sizes. You can also create your own
279279
composite data types by defining messages that are, themselves, data types that
280280
you can assign to a field. In addition to the simple and composite value types,
281-
several common types are published.
282-
283-
### Common Types {#common-types}
284-
285-
* [`Duration`](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/duration.proto)
286-
is a signed, fixed-length span of time, such as 42s.
287-
* [`Timestamp`](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/timestamp.proto)
288-
is a point in time independent of any time zone or calendar, such as
289-
2017-01-15T01:30:15.01Z.
290-
* [`Interval`](https://github.com/googleapis/googleapis/blob/master/google/type/interval.proto)
291-
is a time interval independent of time zone or calendar, such as
292-
2017-01-15T01:30:15.01Z - 2017-01-16T02:30:15.01Z.
293-
* [`Date`](https://github.com/googleapis/googleapis/blob/master/google/type/date.proto)
294-
is a whole calendar date, such as 2025-09-19.
295-
* [`DayOfWeek`](https://github.com/googleapis/googleapis/blob/master/google/type/dayofweek.proto)
296-
is a day of the week, such as Monday.
297-
* [`TimeOfDay`](https://github.com/googleapis/googleapis/blob/master/google/type/timeofday.proto)
298-
is a time of day, such as 10:42:23.
299-
* [`LatLng`](https://github.com/googleapis/googleapis/blob/master/google/type/latlng.proto)
300-
is a latitude/longitude pair, such as 37.386051 latitude and -122.083855
301-
longitude.
302-
* [`Money`](https://github.com/googleapis/googleapis/blob/master/google/type/money.proto)
303-
is an amount of money with its currency type, such as 42 USD.
304-
* [`PostalAddress`](https://github.com/googleapis/googleapis/blob/master/google/type/postal_address.proto)
305-
is a postal address, such as 1600 Amphitheatre Parkway Mountain View, CA
306-
94043 USA.
307-
* [`Color`](https://github.com/googleapis/googleapis/blob/master/google/type/color.proto)
308-
is a color in the RGBA color space.
309-
* [`Month`](https://github.com/googleapis/googleapis/blob/master/google/type/month.proto)
310-
is a month of the year, such as April.
281+
several [common types](/programming-guides/dos-donts#common)
282+
are published.
311283
312284
## History {#history}
313285

content/programming-guides/dos-donts.md

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,24 @@ one is using the field, don’t re-use a tag number. If the change was live ever
1919
there could be serialized versions of your proto in a log
2020
somewhere. Or there could be old code in another server that will break.
2121

22+
<a id="do-reserve-tag-numbers-for-deleted-fields"></a>
23+
24+
## **Do** Reserve Tag Numbers for Deleted Fields {#reserve-tag-numbers}
25+
26+
When you delete a field that's no longer used, reserve its tag number so that no
27+
one accidentally re-uses it in the future. Just `reserved 2, 3;` is enough. No
28+
type required (lets you trim dependencies!). You can also reserve names to avoid
29+
recycling now-deleted field names: `reserved "foo", "bar";`.
30+
31+
<a id="do-reserve-numbers-for-deleted-enum-values"></a>
32+
33+
## **Do** Reserve Numbers for Deleted Enum Values {#reserve-deleted-numbers}
34+
35+
When you delete an enum value that's no longer used, reserve its number so that
36+
no one accidentally re-uses it in the future. Just `reserved 2, 3;` is enough.
37+
You can also reserve names to avoid recycling now-deleted value names: `reserved
38+
"FOO", "BAR";`.
39+
2240
<a id="dont-change-the-type-of-a-field"></a>
2341

2442
## **Don't** Change the Type of a Field {#change-type}
@@ -109,26 +127,31 @@ when a perfectly suitable common type already exists!
109127

110128
### Common Types {#common}
111129

112-
* [interval](https://github.com/googleapis/googleapis/blob/master/google/type/interval.proto)
130+
* [`Duration`](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/duration.proto)
131+
is a signed, fixed-length span of time, such as 42s.
132+
* [`Timestamp`](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/timestamp.proto)
133+
is a point in time independent of any time zone or calendar, such as
134+
2017-01-15T01:30:15.01Z.
135+
* [`interval`](https://github.com/googleapis/googleapis/blob/master/google/type/interval.proto)
113136
is a time interval independent of time zone or calendar (for example,
114137
2017-01-15T01:30:15.01Z - 2017-01-16T02:30:15.01Z).
115-
* [date](https://github.com/googleapis/googleapis/blob/master/google/type/date.proto)
138+
* [`date`](https://github.com/googleapis/googleapis/blob/master/google/type/date.proto)
116139
is a whole calendar date (for example, 2005-09-19).
117-
* [dayofweek](https://github.com/googleapis/googleapis/blob/master/google/type/dayofweek.proto)
140+
* [`dayofweek`](https://github.com/googleapis/googleapis/blob/master/google/type/dayofweek.proto)
118141
is a day of week (for example, Monday).
119-
* [timeofday](https://github.com/googleapis/googleapis/blob/master/google/type/timeofday.proto)
142+
* [`timeofday`](https://github.com/googleapis/googleapis/blob/master/google/type/timeofday.proto)
120143
is a time of day (for example, 10:42:23).
121-
* [latlng](https://github.com/googleapis/googleapis/blob/master/google/type/latlng.proto)
144+
* [`latlng`](https://github.com/googleapis/googleapis/blob/master/google/type/latlng.proto)
122145
is a latitude/longitude pair (for example, 37.386051 latitude and
123146
-122.083855 longitude).
124-
* [money](https://github.com/googleapis/googleapis/blob/master/google/type/money.proto)
147+
* [`money`](https://github.com/googleapis/googleapis/blob/master/google/type/money.proto)
125148
is an amount of money with its currency type (for example, 42 USD).
126-
* [postal_address](https://github.com/googleapis/googleapis/blob/master/google/type/postal_address.proto)
149+
* [`postal_address`](https://github.com/googleapis/googleapis/blob/master/google/type/postal_address.proto)
127150
is a postal address (for example, 1600 Amphitheatre Parkway Mountain View,
128151
CA 94043 USA).
129-
* [color](https://github.com/googleapis/googleapis/blob/master/google/type/color.proto)
152+
* [`color`](https://github.com/googleapis/googleapis/blob/master/google/type/color.proto)
130153
is a color in the RGBA color space.
131-
* [month](https://github.com/googleapis/googleapis/blob/master/google/type/month.proto)
154+
* [`month`](https://github.com/googleapis/googleapis/blob/master/google/type/month.proto)
132155
is a month of year (for example, April).
133156

134157
<a id="do-define-widely-used-message-types-in-separate-files"></a>
@@ -140,24 +163,6 @@ used outside your immediate team, consider putting them in their own file with
140163
no dependencies. Then it's easy for anyone to use those types without
141164
introducing the transitive dependencies in your other proto files.
142165

143-
<a id="do-reserve-tag-numbers-for-deleted-fields"></a>
144-
145-
## **Do** Reserve Tag Numbers for Deleted Fields {#reserve-tag-numbers}
146-
147-
When you delete a field that's no longer used, reserve its tag number so that no
148-
one accidentally re-uses it in the future. Just `reserved 2, 3;` is enough. No
149-
type required (lets you trim dependencies!). You can also reserve names to avoid
150-
recycling now-deleted field names: `reserved "foo", "bar";`.
151-
152-
<a id="do-reserve-numbers-for-deleted-enum-values"></a>
153-
154-
## **Do** Reserve Numbers for Deleted Enum Values {#reserve-deleted-numbers}
155-
156-
When you delete an enum value that's no longer used, reserve its number so that
157-
no one accidentally re-uses it in the future. Just `reserved 2, 3;` is enough.
158-
You can also reserve names to avoid recycling now-deleted value names: `reserved
159-
"FOO", "BAR";`.
160-
161166
<a id="dont-change-the-default-value-of-a-field"></a>
162167

163168
## **Don't** Change the Default Value of a Field {#change-default-value}

content/programming-guides/proto2.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,8 +1141,9 @@ protect participants from reusing extension field numbers.
11411141

11421142
**Unverified extension field number allocation strategies are not recommended**
11431143
because the [Consequences of Reusing Field Numbers](#consequences) fall on all
1144-
extenders of a message (not just the developer that didn't follow the rules). If
1145-
your use case requires very low coordination, consider using the
1144+
extenders of a message (not just the developer that didn't follow the
1145+
recommendations). If your use case requires very low coordination, consider
1146+
using the
11461147
[`Any` message](/reference/protobuf/google.protobuf#any)
11471148
instead.
11481149

content/reference/cpp/recommended-downcast-method.md

Lines changed: 0 additions & 156 deletions
This file was deleted.

0 commit comments

Comments
 (0)