On Tue, Aug 7, 2012 at 12:47 AM, Stack <st...@duboce.net> wrote: > On Mon, Aug 6, 2012 at 11:39 PM, Chris Trezzo <ctre...@gmail.com> wrote: > > Some engineers at Google have come to the conclusion that using > > requireddoes more harm than good; they prefer to use only > > optional and repeated. However, this view is not universal." > > > > Thoughts? > > > > How hard adding the logic Chris? Any 'costs' associated. > > St.Ack >
I've found (in my limited experience) that it ends up being a single helper/util function per message, though at worst it can be one helper per element in the message. The latter comes about if you have an optional element that also has some optional elements. In that case you need to make sure that (1) the message content there and (2) enough of the content is there. Fortunately, this is usually a pretty fast check, just checking the presence of fields per RPC (and each object has generated has___() methods for this checking), so its not too terrible since the boolean checks are pretty fast (and using generalized RPC already has a bunch of overhead too :). This can theoretically lead to a proliferation of helper functions that validate message/message contents for lots of different cases. In reality though, I think this ends up being at most 2-3 per message type (at _worst_) given then relative simplicity of our RPCs. If we go with this, we will probably have to a have a helper/validator cleanup when its gets out of control. ------------------- Jesse Yates @jesse_yates jyates.github.com