Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8149417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:50:50+00:00 2026-06-06T14:50:50+00:00

Protocol Buffer documentation warns that … You should never add behaviour to the generated

  • 0

Protocol Buffer documentation warns that …

You should never add behaviour to the generated classes by inheriting
from them. This will break internal mechanisms and is not good
object-oriented practice anyway.

source:Protocol Buffer Basics

My two part question is:

  1. What internal mechanisms could this break?
  2. In what way is this not good a good OO practice anyway?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T14:50:51+00:00Added an answer on June 6, 2026 at 2:50 pm
    1. “What goes wrong” is going to be very implementation specific. If you cited a specific implementation, it might be possible to answer, but in the more general sense: this is not a supported scenario, and implementations are not required to work correctly or at all if you subclass. This is an undefined behaviour, with all that implies. Further, protocol buffers does not support inheritance, because not all target platforms can support it. Key thoughts:

      • there may be code that checks the incoming object against a list of expected types – if yours isn’t there, it could fail
      • it won’t handle any fields etc that you add
      • the whole idea of a serializer is to robustly give back what you serialized; if you serialize a SomeDerivedClass, there’s no way the serializer can give you that back
      • the entire point of a library like this is to hide away gory implementation details; you are not expected to be messing with any of the implementation (polymorphism must be designed for)
    2. As an OO concern; this is not your type; it is a DTO that is designed to serve a specific purpose. Common usage might be to map from the DTO to/from your domain model, which can be more complex, or possibly to encapsulate the DTO if that is useful (perhaps as a façade).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some problems at runtime with some of my generated protocol buffer classes.
I'm trying to send messages generated by Google Protocol Buffer code via a simple
Though I've followed the excellent Protocol Buffer documentation and tutorials for C++ and Python,
I have the below protocol buffer. Note that StockStatic is a repeated field. message
I am new to protocol buffer from google so I tried the Java tutorial
I am using web.py to return a protocol buffer response from a post request
I created a basic TCP server that reads incoming binary data in protocol buffer
I'm developing a simple protocol that is used to read/write integer values from/to a
I'd like to use protocol buffer in my program to read data from a
Reading into Protocol Buffer Basics: C++ , found nothing that matches the situation:; with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.