Loading...
Loading...
Compare original and translation side by side
| Principle | Description |
|---|---|
| Imperative shell, functional core—separate pure logic from I/O |
| 原则 | 描述 |
|---|---|
| 命令式外壳,函数式核心——将纯逻辑与I/O分离 |
| Principle | Description |
|---|---|
| Make illegal states unrepresentable via type design |
| One reason to change per unit |
| Validated types at boundaries |
| Prefer composition over inheritance |
| Open for extension, closed for modification |
| No hidden globals or implicit state |
| Surface errors immediately with context |
| Errors should be identifiable to allow action |
| Const/readonly by default |
| Unions/enums over magic strings |
| Left-hand side is the happy path (Go style early returns) |
| 原则 | 描述 |
|---|---|
| 通过类型设计让非法状态无法被表示 |
| 每个单元只有一个变更理由 |
| 在边界处使用已验证的类型 |
| 优先使用组合而非继承 |
| 对扩展开放,对修改关闭 |
| 无隐藏全局变量或隐式状态 |
| 立即附带上下文暴露错误 |
| 错误应可被识别以便采取行动 |
| 默认使用Const/Readonly |
| 使用联合类型/枚举替代魔法字符串 |
| 左侧为正常路径(Go风格提前返回) |