agentleFS
13eholder13eholder/Modern-Cpp-Skills/m09-domain/SKILL.md

m09-domain

Skill14 starsChanged 9 months agoMITView on GitHub

Mastering C++ Domain Modeling (DDD). Triggers: Entity, Value Object, Aggregate, Repository, Pimpl, Class Design, Invariant.

7 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Files
SKILL.md

C++ Domain Modeling

Core Question

Identity or Value?

  • Value Object: Defined by attributes (Color, Money). Equality via comparison. Copyable.
  • Entity: Defined by Identity (User, Socket). Equality via ID. Non-copyable (usually).

Error → Design Question

IssueDesign Question
Data InconsistencyAre public fields allowing invalid states?
Object SlicingAre you passing polymorphic Entities by Value?
Header HellAre you leaking implementation details? (Use Pimpl).

Thinking Prompt

  1. Is it copyable?
    • Yes? → Value Type (Rule of Zero, defaults).
    • No? → Entity (Delete copy ctor, enable move).
  2. Does it have invariants?
    • Yes? → class with private data + public methods.
    • No? → struct (POD).
  3. Does it own others?
    • Aggregate Root? → Owns children via std::vector / unique_ptr.

Trace Up / Down

  • Trace Down:
    • Intent: "User has a Name and an Address."
    • Code: class User (Entity) holds Name (Value) and Address (Value).

Quick Reference

PatternC++ Implementation
Value Objectstruct + operator<=>.
Entityclass + Deleted Copy + ID field.
RepositoryPure Virtual Interface (virtual ... = 0).
AggregateParent class owning children.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.