unix-software-design
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese模块化原则
Modularity Principles
- Rule of Modularity: 编写简单部件,通过清晰接口连接。
- Rule of Composition: 设计程序以便与其他程序连接。
- Rule of Separation: 分离策略与机制;分离接口与引擎。
- Rule of Modularity: Write simple components, connected through clear interfaces.
- Rule of Composition: Design programs to be connectable with other programs.
- Rule of Separation: Separate strategy from mechanism; separate interface from engine.
简洁性原则
Simplicity Principles
- Rule of Clarity: 清晰优于巧妙。
- Rule of Simplicity: 为简洁而设计;仅在必要时才增加复杂性。
- Rule of Parsimony: 仅在明确证明别无他法时才写大程序。
- Rule of Extensible: 为未来设计,因为它会比你想象的更快到来。
- Rule of Clarity: Clarity is better than cleverness.
- Rule of Simplicity: Design for simplicity; only add complexity when necessary.
- Rule of Parsimony: Write large programs only when it is clearly proven that there is no alternative.
- Rule of Extensible: Design for the future, as it will come faster than you think.
健壮性原则
Robustness Principles
- Rule of Transparency: 为可见设计,使检查和调试更容易。
- Rule of Robustness: 健壮性是透明和简洁的产物。
- Rule of Representation: 将知识融入数据,使程序逻辑可以更简单和健壮。
- Rule of Least Surprise: 在界面设计中,始终做最不令人惊讶的事。
- Rule of Silence: 当程序无话可说时,应该什么都不说。
- Rule of Repair: 必须失败时,要尽快大声地失败。
- Rule of Transparency: Design for visibility to make inspection and debugging easier.
- Rule of Robustness: Robustness is the product of transparency and simplicity.
- Rule of Representation: Embed knowledge in data so that program logic can be simpler and more robust.
- Rule of Least Surprise: In interface design, always do the least surprising thing.
- Rule of Silence: When a program has nothing to say, it should say nothing.
- Rule of Repair: When you have to fail, fail fast and loudly.
效率原则
Efficiency Principles
- Rule of Economy: 程序员时间昂贵;优先节省程序员时间而非机器时间。
- Rule of Generation: 避免手写代码;用代码生成器(如 protobuf、SQLAlchemy、cargo-generate)替代重复劳动。
- Rule of Optimization: 原型先于优化。先让它工作,再用 profiling 工具定位瓶颈后优化。
- Rule of Economy: Programmer time is expensive; prioritize saving programmer time over machine time.
- Rule of Generation: Avoid writing code manually; use code generators (such as protobuf, SQLAlchemy, cargo-generate) to replace repetitive work.
- Rule of Optimization: Prototype comes before optimization. Make it work first, then optimize after locating bottlenecks with profiling tools.
多元性原则
Diversity Principles
- Rule of Diversity: 质疑"唯一正确方式"的所有声明。
- Rule of Diversity: Question all claims of "the only correct way".
补充原则
Supplementary Principles
- 尽可能将数据流设计为文本格式(便于用标准工具查看和过滤)。
- 数据库布局和应用程序协议应尽可能采用文本格式(JSON/YAML/TOML,人类可读和可编辑)。
- 复杂前端(用户界面)应与复杂后端清晰分离。
- 优先使用 Rust/Go/Zig 等现代系统级语言;用 Python/TypeScript 快速原型后再用编译型语言优化关键路径。
- 用 uv 管理 Python 依赖,用 cargo 管理 Rust 依赖,用 npm/pnpm 管理 JS 依赖。
- 对输入慷慨,对输出严格。
- 过滤时永远不要丢弃不需要的信息。
- 小即美。编写尽可能少做与完成任务一致的程序。
- 用 Docker/容器化封装应用,确保开发与生产环境一致。
- 用 CI/CD 流水线自动化测试和部署。
- Design data streams in text format as much as possible (easy to view and filter with standard tools).
- Database layouts and application protocols should adopt text format as much as possible (JSON/YAML/TOML, human-readable and editable).
- Complex frontends (user interfaces) should be clearly separated from complex backends.
- Prioritize modern system-level languages such as Rust/Go/Zig; quickly build prototypes with Python/TypeScript, then optimize critical paths with compiled languages.
- Use uv to manage Python dependencies, cargo to manage Rust dependencies, and npm/pnpm to manage JS dependencies.
- Be generous with input and strict with output.
- Never discard unwanted information when filtering.
- Small is beautiful. Write programs that do as little as possible while being consistent with completing the task.
- Encapsulate applications with Docker/containerization to ensure consistency between development and production environments.
- Automate testing and deployment with CI/CD pipelines.