gof-design-patterns
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGoF Design Patterns
GoF设计模式
Goal
目标
- Choose the simplest design that solves the real change pressure.
- Select one primary pattern (two only if responsibilities are clearly split).
- Keep recommendations language-agnostic and explicit about tradeoffs.
- Support coding tasks with pattern-aligned implementation guidance.
- 选择能解决实际变更需求的最简设计方案。
- 选择一种主要模式(仅当职责明确拆分时可选择两种)。
- 保持建议与语言无关,并明确说明权衡取舍。
- 提供与模式匹配的实现指导,以支持编码任务。
Simple Workflow
简易工作流
- Capture context with three questions: what changes often, what hurts now, and which constraint dominates.
- Shortlist up to three candidates using (canonical source). Use
references/DECISION_FRAMEWORK.mdonly for quick intent lookup.references/CATALOG.md - Select one pattern (or ) based on future change-cost reduction and lower indirection.
do not use a pattern - If the task includes code changes, always read both:
references/pattern-<selected-pattern>.md- (illustrative reference only)
scripts/<selected-pattern>.ts
- Apply the design incrementally, adapted to the project language and constraints.
- Validate with , then run a final quality/activation self-check with
references/PITFALLS.md, and format the answer withreferences/TESTS.md.references/OUTPUT_TEMPLATES.md
- 通过三个问题捕捉上下文:哪些内容经常变更、当前存在哪些痛点、哪个约束条件起主导作用。
- 使用(权威来源)筛选出最多三个候选模式。仅在快速查找模式意图时使用
references/DECISION_FRAMEWORK.md。references/CATALOG.md - 基于降低未来变更成本和减少间接性的原则,选择一种模式(或选择)。
不使用设计模式 - 如果任务涉及代码变更,务必阅读以下两个文件:
references/pattern-<selected-pattern>.md- (仅作演示参考)
scripts/<selected-pattern>.ts
- 逐步应用设计方案,并根据项目语言和约束条件进行适配。
- 使用验证设计,然后通过
references/PITFALLS.md进行最终的质量/生效自检,最后按照references/TESTS.md格式化答案。references/OUTPUT_TEMPLATES.md
Core Rules
核心规则
- Language first: choose by problem forces and context, not by language syntax.
- Simplicity first: if recurring change pressure is weak, explicitly recommend .
do not use a pattern - Script policy: scripts are examples to read and adapt, not mandatory to execute.
- 语言优先:根据问题本身和上下文选择模式,而非语言语法。
- 简洁优先:如果反复变更的需求较弱,明确建议。
不使用设计模式 - 脚本规则:脚本仅作参考和适配使用,并非强制执行。
Output Contract
输出规范
- Always provide an explicit decision.
- Always include one simpler alternative and why it was rejected.
- Always include tradeoffs (and
Pros).Cons - If code is shown, include a short adaptation note for other languages.
- 始终提供明确的决策结果。
- 始终包含一种更简单的替代方案,并说明拒绝该方案的原因。
- 始终包含权衡分析(和
优点)。缺点 - 如果展示代码,需添加针对其他语言的简短适配说明。
Navigation
导航
Core References
核心参考文档
- Decision Framework
- Catalog
- Pitfalls and Anti-Patterns
- Output Templates
- Trigger Tests
- 决策框架
- 模式目录
- 常见陷阱与反模式
- 输出模板
- 触发测试
Pattern Cards
模式卡片
- Abstract Factory
- Adapter
- Bridge
- Builder
- Chain of Responsibility
- Command
- Composite
- Decorator
- Facade
- Factory Method
- Flyweight
- Interpreter
- Iterator
- Mediator
- Memento
- Observer
- Prototype
- Proxy
- Singleton
- State
- Strategy
- Template Method
- Visitor
- 抽象工厂模式
- 适配器模式
- 桥接模式
- 建造者模式
- 责任链模式
- 命令模式
- 组合模式
- 装饰器模式
- 外观模式
- 工厂方法模式
- 享元模式
- 解释器模式
- 迭代器模式
- 中介者模式
- 备忘录模式
- 观察者模式
- 原型模式
- 代理模式
- 单例模式
- 状态模式
- 策略模式
- 模板方法模式
- 访问者模式