I think the general spirit of protobuf is to assume not every field needs to be filled out on a message just because you reference it in a new context. Additionally, you could do request validation to ensure they aren't set if you're worried people might misunderstand.
On Mon, Jan 21, 2019, 11:42 AM <[email protected]> wrote: > Hello, > > I have been working with protobuf for a few months. I've noticed a very > bad pattern: I had to copy and paste data types again and again. > > For example, let's say we have the `User` type with `username`, `mail` and > `name`. Now, we want to add a `SearchUserRequest`, which is the same as > `User` but its fields are inside a `oneof`. Now, we'll have to copy all of > `User`'s fields to `SearchUserRequest`'s `oneof`. That causes code > duplication which leads to duplicate messages and a pain to maintain. > > My idea was to add a special macro-message which builds a new message on > top of the other one. For example (Pseudo code): > mutate User as SearchUserRequest { > # Disallow searching by email. > remove email; > } > > > > Please let me know if you think the same, if there is another way to solve > this problem, and what do you think about my solution. > Shmuel. > > -- > You received this message because you are subscribed to the Google Groups > "Protocol Buffers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/protobuf. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
