3 ms·
> you want to do a "has" check before accessing a field You should only do that if the semantics of the not-set field are different than the default value, whi
by tantalor 2y ago
> you want to do a "has" check before accessing a field
You should only do that if the semantics of the not-set field are different than the default value, which should be rare and documented on the field.
- ynniv 2y agoI too enjoy defining my default attribute values at the protocol level, so they can never, ever be changed, and then defensively coding library functions in case the arguments are not constructed under the same semantic assumptions as I had years ago. Also everything needs to be marked optional or you'll need to restart the whole service mesh to change the schema.
- kyrra 2y agoDefault values in proto are considered an anti pattern and was removed from the language in proto3. Agreed that protocol level required is bad, and it's with proto3 made optional the default. Our team enforces required fields via proto annotations, which can be much more flexible (we have transitional states to be able to upgrade or downgrade the check)
- deleted 2y ago[deleted]