redesign-from-first-principles

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Redesign-from-first-principles

从第一性原理重新设计

Do not bolt the change onto what exists. Design as if the requirement had been there from the first day.
  • Read every affected part and say what the current design is for.
  • Ask: if we wrote this from scratch today, with this requirement, what would we build? Existing tickets, stacks and code are inputs. They are not limits.
  • Prefer deleting to simplifying, simplifying to optimizing, and optimizing to automating. A refactor removes more than it adds. If it grows the code, name what the growth buys, or stop.
  • Never rebuild the old design under new names. Spend no work on code that the redesign deletes.
  • Move every caller to the new shape and delete the old path in the same change. No shims, and no old and new paths side by side.
  • Carry the change through every reference: types, tests, documents, examples, drawings.
  • Think the whole redesign through. Then deliver it in steps that each work.
A reviewer uses the same question as a verdict: is this what one would build from scratch for its requirements, and is it carried through every reference?
不要把变更生硬地嫁接到现有实现上。应假定该需求从第一天起就存在,并据此进行设计。
  • 阅读所有受影响的部分,说明当前设计的用途。
  • 问自己:如果我们今天从零开始编写,并包含这个需求,会构建什么?现有工单、技术栈和代码都是输入,而非限制。
  • 优先删除,其次简化,再次优化,最后自动化。重构应做到减法多于加法。如果代码量增加,说明新增内容带来了什么价值,否则就停止。
  • 绝不要只是给旧设计换上新名字。不要在重设计将删除的代码上投入任何工作。
  • 在同一次变更中,将所有调用方迁移到新形态并删除旧路径。不保留 shim,也不让新旧路径并存。
  • 将变更贯彻到每一个引用处:类型、测试、文档、示例和设计图。
  • 全面思考整个重设计过程,然后以每一步都可独立工作的方式交付。
评审者会用同一个问题作出结论:如果根据其需求从零开始构建,是否会采用当前设计?以及该变更是否已贯彻到每一个引用处?