I Ban the Second Way of Doing Anything: What That Costs
说明与用途
开发者在多个仓库中实施“单一路径”规则,消除了代码重复,提升了可维护性和构建可靠性。
问题
Developers often create duplicate implementation paths for the same meaning, leading to maintenance overhead and hidden bugs.
结果
Duplicate implementation paths were eliminated across five repositories, reducing maintenance effort and catching hidden bugs. The rule enforcement also revealed the author's own mistakes.
工作流
- Define a rule: one meaning, one implementation path.
- Add rule text, enforcement matrix, and build check to the repo.
- Validate docs and matrix against each other in the build.
- Implement a conformance checker that rejects disallowed patterns.
- Add proof documents that quote real output for each gate.
- Run the build to ensure all rules fire.
- Iterate on rules, marking them as mechanical, partially, planned, or impossible.
- Maintain the rule set with human oversight where needed.
证据
I tested how far this goes by starting five small repositories in six days — Kotlin, C#, Go, Rust, Java — each with the same constitution, the same rule IDs, the same demand that every rule declare whether a machine enforces it or a person does. Five languages, one rule, 159 merged pull requests.
Adding a rule touches three places. The rule text, the enforcement matrix that says how it's held, and the actual check.
The second path stopped appearing. Not because people got better — because the build got red.
- 记录日期: 2026-09-11T04:46:25.808Z