Encapsulation of vocabulary types #36842

issue purpleKarrot opened this issue on November 12, 2026
  1. purpleKarrot commented at 9:25 AM on November 12, 2026: contributor

    Several ongoing PRs address different aspects of encapsulation:

    Looking at the earlier attempts referenced by #35511 (#4067 and #5430 from 2014), what strikes me is that the same fundamental design questions have been debated for more than twelve years, with essentially the same arguments repeated over and over.

    The fundamental engineering question is not particularly exotic. Encapsulation has been an established principle of software engineering for decades: a type should expose its semantics, not its representation.

    Yet we continue to debate individual applications of this principle as though each were a new architectural question. The cost and risk of changing existing code repeatedly become arguments for retaining the coupling that makes those changes costly and risky in the first place.

    I propose that we adopt encapsulation and regular value semantics as general design guidelines for vocabulary types:

    • Data members should be private. Public member functions and free functions should express meaningful operations rather than merely reproduce access to the underlying representation through getters and setters. No inheritance or abstract base classes are implied.
    • Vocabulary types should have regular value semantics, including copyability and assignability. This rules out const and reference data members, which prevent ordinary assignment.

    This issue proposes a design guideline, not a rewrite or refactoring initiative. Identifying existing violations, planning migrations, and evaluating the costs and risks of individual changes are outside its scope. Those questions belong in the respective implementation PRs.

    The purpose of this issue is to establish a shared engineering direction, so that future reviews can focus on how to apply these principles rather than repeatedly debating whether they should apply at all.

  2. maflcko added the label Brainstorming on Nov 12, 2026
  3. maflcko added the label Docs on Nov 12, 2026

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-11-16 17:51 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me