C++ Design Boundaries: Start with Requirements¶
Start with the work the program must do, not a hierarchy of domain nouns. We will explain where changes belong, who can write state, and how we know a change is correct.
What Big OOPs Contributes¶
The edited Big OOPs transcript questions object-centred encapsulation boundaries and invites consideration of system-centred access. It does not establish that every program should become ECS. Historical claims remain the speaker's account, not facts independently verified here.
Our interpretation is a question: which boundary makes the required operation understandable? We will test behaviour and inspect modification points, not treat the talk as a prescription.
Write Requirements Before Classes¶
A body has a position. Movement, visibility, and lifetime are independent capabilities. A stationary visible decoration and an invisible moving body are both valid.
| Requirement | Observable result | Owner or writer |
|---|---|---|
| Movement | Position changes using velocity | Simulation world |
| Visibility | Visible surviving positions enter a render snapshot | Renderer reads; it does not move bodies |
| Lifetime | An expiring body gets its final movement, then disappears | Lifetime pass and cleanup |
| Invalid time step | Reject without modifying state | Step entry point |
| Later acceleration | Velocity changes before position | Ordered motion operation |
| Later persistent selection | Selection survives unrelated deletions | World-issued identity |
Rendering produces data, not a window. We leave out collisions, networking, threads, GPIO, and performance targets. Each would need another contract.
Separate Meaning, Ownership, and Access¶
“Projectile” is domain meaning. It does not determine whether velocity belongs in a record, an owned Motion value, or a separate store. Processing many bodies does not mean arbitrary functions should mutate everything.
Both need an owner. The first keeps behaviour together; the second makes one operation across many bodies explicit. Neither diagram proves speed or maintainability.
Evidence We Will Collect¶
For every design, identify:
- The actual edits needed to add acceleration.
- Each writer along one body's frame.
- The invariant preventing an invalid capability combination.
- The lifetime of a returned observation.
- The machinery a maintainer must understand.
Equivalent output is necessary but not sufficient: implementations can share a bug. We calculate expected trajectories independently and later reproduce a deliberate visibility bug.
Know When to Stop¶
If direct records satisfy the requirements and remain easy to inspect, stop there. IDs solve persistent references; ECS separates capability processing; queues define change visibility. They are distinct requirements, not levels in a mandatory upgrade ladder.
Classes, RAII, composition, and selected design patterns remain useful. This course compares boundaries rather than banning OOP.
Exercise¶
Write a requirement for an invisible moving body. What should its position and render output be after one step? Keep the answer: it becomes a regression test in chapter 8.
Next: establish the smallest implementation and its observation boundary.