![]() |
vkmEngine 1.0.15
A C++ game engine · vkmengine.com
|
How to look at code that already exists and ask is this the shape the engine should have? - and how to review a change (section 7). A hunt for defects finds defects while the design goes wrong underneath; nobody hunting bugs in a file concludes that the file should not exist.
Every one of these is the same failure: the code stopped expressing the design and started depending on someone remembering it.
| Tell | What it means |
|---|---|
| An invariant living in a comment | The structure refuses to encode a rule |
| A field per case | Fixes accreting where a mechanism belongs |
| A guard instead of a state | A state that was never modelled |
| One fact stated twice | Two owners, and one of them will drift |
| One concept, several mechanisms | Nobody chose, so everybody chose |
| A class holding unrelated state | A container that grew instead of a design |
| The same file fixed again and again | The design is telling you something |
| A comment that argues | A decision defended instead of expressed |
| Something kept for a user | A shape the engine would not choose today |
Prose like "Must precede scene I/O" says there is a rule the code does not hold. The fix is rarely a better comment: it is a type, a constructor that cannot be called out of order, or one shared sequence with a single home (bootHost in tools/project_boot.h for the hosts' prologue). Some constraints are too small to be worth a type; acting is a judgment.
When something new must survive an operation and the answer is another member, the mechanism is accumulating rather than generalising: fields added one incident at a time, each with its own rule. Ask: would one more case be absorbed, or grow it again?
A check every caller must remember - "refuse this during play" asked by each save path - means the new operation that forgets is a bug. A state the code can be in beats a question every caller must remember to ask.
The defect this engine's reviews find most. A fact with two owners - a constant mirrored in GLSL, a rule re-implemented in a second file, a comment and the code it describes, a doc page and the struct it lists - is correct only until one of them changes, and the second copy is usually right the day it is written.
Ask what else states a fact before asking whether this copy is wrong. The fix is one owner: a shared constant, a generated list, a helper both call, or a check that fails the suite when the two disagree (tests/docs/docs_tests.cpp for docs against source).
Count the ways the engine does one thing. Each of several persistence paths can be right while the sum is unmaintainable: a fix in one never reaches the others.
Read a class's members as a list and ask whether they are one idea. Members that each change for reasons unrelated to the others - which file is open, what a widget shows, what Play captured - are a container, not a design.
The cheapest signal, because it is history rather than opinion:
git log --since=6.months --format=%x01%s --name-only -- src |
awk '/^\x01fix/{f=1;next} /^\x01/{f=0} f&&/\.(cpp|h)$/{print}' |
sort | uniq -c | sort -rn
A file that moved counts under each of its names; add them. Read a file's last five fixes together. If each adds a case rather than removing the reason for cases, the design is the defect and the fixes are interest. If the fixes removed cases, the rank is not a verdict.
A comment defending a decision is doing a commit message's job, and usually sits where the author knew the design was questionable. Treat it as a pointer to the thing being justified (code-style.md).
An alias, an overload, a fallback, a tolerated old spelling or a comment saying "for X" that exists because a game, an example or an old file relies on it. The engine would not have it if it were designed today (design.md). Report it with its users; the fix is to delete it and port them (implementation.md).
Does this thing make the next thing easier, or harder? A smoothing design absorbs the next case without changing shape; a suffocating one makes everything work around it.
Do people extend it, or route around it? Count the callers that bypass it, duplicate a piece of it, or reach past it to what it wraps: a second path to the same outcome, a caller reconstructing internals, a helper that exists to avoid it, a comment saying "we do it this way here because X does not handle Y." Three bypasses mean suffocating however clean it looks - usually reasonable code holding a responsibility that was the wrong one to centralise.
Redesign when the cost of the next change is rising - each fix larger than the last, or adding a case rather than removing the reason for cases. Patch when the thing is done and merely imperfect - it works, it is not growing, nothing new is being built on it.
Approve a change when it leaves the engine better than it found it, even if it is not how you would have written it.
Look in the order that finds the expensive problems first:
Before a release, the comments the release touched get one more read, by a reviewer whose only job is to refute them: open the code each sentence describes and check it is still true. A rewrite of a comment is where invented mechanisms come from.
A branch is judged at its last commit. The tip must build and pass every suite; the commits before it need not each build, and nobody spends a machine's hours proving they do. Polishing history - reordering, folding fixes into the commits they belong to - is checked by the tip's tree matching the one that was tested.
Say which of your comments block and which are suggestions. A defect, a broken absolute, an unmeasured performance claim, docs that did not ship and a half-finished refactor block. Everything in section 2 does not.