Search code examples
coding-stylenaming-conventionsprotocol-buffersnaming

What is best file naming style for protobuf?


There is a Style Guide for Protocol Buffers. But it does not clearly say how a .proto file should be named.

MyProtos.proto, my_protos.proto or my-protos.proto, which is the better name?


Solution

  • I don't believe there's an appropriate answer to how any file "should be named" other than aim for consistency and clarity.

    Consistency would mean following the file-naming conventions your project already has for sources and headers. If your sources are named using camel-case, do the same for the proto files. The most common choice seems to me to be the my_protos.proto version.

    Clarity to me means that the file name should give some clue as to the contents. I generally favour naming files after the class which they implement, and usually have a separate file (pair) per class. I would recommend the same for the proto files. I prefer several small proto files each defining a single Message or very closely related Messages over a single huge proto file defining all your Messages in the one place.