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:

  1. what internal mechanisms break?
  2. in way not good oo practice anyway?

  1. "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)
  2. 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

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -