Inheriting from generated Protocol Buffer classes -
protocol buffer documentation warns ...
you should never add behaviour generated classes inheriting them. break internal mechanisms , not object-oriented practice anyway.
source:protocol buffer basics
my 2 part question is:
- what internal mechanisms break?
- in way not good oo practice anyway?
"what goes wrong" going implementation specific. if cited specific implementation, might possible answer, in more general sense: not supported scenario, , implementations not required work correctly or @ if subclass. undefined behaviour, implies. further, protocol buffers not support inheritance, because not target platforms can support it. key thoughts:
- there may code checks incoming object against list of expected types - if yours isn't there, fail
- it won't handle fields etc add
- the whole idea of serializer robustly give serialized; if serialize
somederivedclass
, there's no way serializer can give back - the entire point of library hide away gory implementation details; not expected messing of implementation (polymorphism must designed for)
as oo concern; not type; dto designed serve specific purpose. common usage might map dto to/from domain model, can more complex, or possibly encapsulate dto if useful (perhaps façade).
Comments
Post a Comment