Inheritance in protocol buffers
How to handle inheritance in Google Protocol Buffers 3.0? Java equivalent code: public class Bar { String name; } public class Foo extends Bar { String id; } What would be Proto equivalent code? message Bar { string name = 1; } message Foo { string id = 2; } Protocol Buffers does not support inheritance. Instead, consider using composition: message Foo { Bar bar = 1; string id = 2; } However, that said, there is a trick you can use which is like inheritance -- but which is an ugly hack, so you should only use it with care. If you define your message types like: message Bar { string name = 1; }