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
Issue
Design Question
Data Inconsistency
Are public fields allowing invalid states?
Object Slicing
Are you passing polymorphic Entities by Value?
Header Hell
Are you leaking implementation details? (Use Pimpl).
Thinking Prompt
Is it copyable?
Yes? → Value Type (Rule of Zero, defaults).
No? → Entity (Delete copy ctor, enable move).
Does it have invariants?
Yes? → class with private data + public methods.
No? → struct (POD).
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
Pattern
C++ Implementation
Value Object
struct + operator<=>.
Entity
class + Deleted Copy + ID field.
Repository
Pure Virtual Interface (virtual ... = 0).
Aggregate
Parent class owning children.
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: 13eholder-modern-cpp-skills-m09-domain3description: C++ Domain Modeling4---56# C++ Domain Modeling78## Core Question910**Identity or Value?**1112- **Value Object**: Defined by attributes (`Color`, `Money`). Equality via comparison. Copyable.13- **Entity**: Defined by Identity (`User`, `Socket`). Equality via ID. Non-copyable (usually).1415## Error → Design Question1617| Issue | Design Question |18| ---------------------- | ---------------------------------------------------- |19| **Data Inconsistency** | Are public fields allowing invalid states? |20| **Object Slicing** | Are you passing polymorphic Entities by Value? |21| **Header Hell** | Are you leaking implementation details? (Use Pimpl). |2223## Thinking Prompt24251. **Is it copyable?**26 - Yes? → Value Type (Rule of Zero, defaults).27 - No? → Entity (Delete copy ctor, enable move).28292. **Does it have invariants?**30 - Yes? → `class` with private data + public methods.31 - No? → `struct` (POD).32333. **Does it own others?**34 - Aggregate Root? → Owns children via `std::vector` / `unique_ptr`.3536## Trace Up / Down3738- **Trace Down**:39 - *Intent*: "User has a Name and an Address."40 - *Code*: `class User` (Entity) holds `Name` (Value) and `Address` (Value).4142## Quick Reference4344| Pattern | C++ Implementation |45| ---------------- | ------------------------------------------- |46| **Value Object** | `struct` + `operator<=>`. |47| **Entity** | `class` + Deleted Copy + ID field. |48| **Repository** | Pure Virtual Interface (`virtual ... = 0`). |49| **Aggregate** | Parent class owning children. |5051---52> Converted and distributed by [TomeVault](https://tomevault.io/claim/13eholder) — claim your Tome and manage your conversions.53<!-- tomevault:4.0:skill_md:2026-04-11 -->
Run npx skillmds@latest add tomevault-io/13eholder-modern-cpp-skills-m09-domain in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
C++ Domain Modeling It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
tomevault-io (@tomevault-io) published this skill. Their other Agent Skills are listed on their SkillMD profile.