Besides the rather short Google provided style guide , here are my thoughts on the Google Protocol Buffer message names.
Use the "Message" at the end of the message type names.
- This makes it easy to see in the source code that the class is a class generated by the proto-buf. This also has the advantage that if I have a class with a rich domain, then it can have a real name, for example AddressBookMessage for the protobuf class and AddressBook for the real class.
For Java users, it seems that java_outer_classname end in Protos is standard.
- I did not notice this at the initial stage, so my current protobuf classes are in
com.example.project.protobuf.MyProtos , but I see no reason to keep it there, since we need to have a containing class, so it can be com.example.protobuf.MyProtos to com.example.protobuf.MyProtos if there are no classes in the top package of the project.
Start enums at 0 according to C / C ++.
Use a unique name for the repeated field.
- Most of the generated methods sound better with a unique field name, even if it is repeated, for example. message-> add_child (), not message-> add_children () if you had a repeated child field.
Are there any other standards that people use or differ from?
protocol-buffers
Blair zajac
source share