Comment #3 on issue 460 by xiaof...@google.com: Add isDefault() to Java Message interface as a fast means to verify whether it is a default instance
http://code.google.com/p/protobuf/issues/detail?id=460

Re 1, 2, 4: When the default instance is used is an implementation detail. The fact that it's used extensively in protobuf's implementation doesn't mean it should also be used in users' code. The "message == message.getDefaultInstnaceForType()" pattern is discouraged and may lead to buggy code. For example, when hasFoo() is false, getFoo() may return an empty Foo object but not necessarily the default instance. Rather than "isDefault()", I think what you actually want is "isEmpty()" and "getSerializedSize() == 0" serves this purpose well enough. Re 3, 5, 6: Introducing an new method to the interface doesn't improve the performance. It simply makes it easier to write the "message == message.getDefaultInstanceForType()" stuff, which I regard as an anti-pattern of using protobufs. Re 7: This is a project used widely at Google. Every addition to the interface has a great cost.
Overall, I don't think we should add "isDefault()" to the interface.

--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
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 protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to