I have a protobuf message like this:
message MyMessage{
string foo = 1;
int toBeRemovedBar = 2 [deprecated = true];
string zag = 3;
}
toBeRemovedBar attribute is no longer required and needs to be removed. As per the guidelines here and here, I could reserve either the field name or the number. What is the best practice here?
- Reserve either the field number or name
- Reserve both field number and name
Reserving field number would prevent only the reuse of the field number. Reuse of the field name could not be prevented. Similar argument holds good for reserving only the field name.
So, the right way to remove an attribute is to reserve both field name and number as given below?
message MyMessage{
string foo = 1;
reserved 2;
reserved "toBeRemovedBar";
string zag = 3;
}
It seems good to me.
In this way you prevent both the field number and the name from being used in future. I did the same in a work project because I had to be sure that both the field number and the name wouldn't be used again.