设计模式在以下情况下是有价值的:解决你实际拥有的真实问题 — 但是在不适合的地方强行使用它们会导致过度设计。关于何时(以及何时不)使用模式的判断力和了解模式本身一样重要。
当模式适用于真实问题时使用它们
✓ When you have a problem a pattern is DESIGNED to solve (recognize the situation)
✓ When the pattern genuinely makes the code better (more flexible, maintainable, clear)
✓ When the added structure is JUSTIFIED by real needs (flexibility you'll actually use)
✓ When it improves communication (a well-known pattern others will recognize)
→ patterns are TOOLS for specific problems → apply them to the right problems
不要强行使用模式(避免过度设计)
✗ DON'T add a pattern just to use it ("pattern for its own sake") → adds needless complexity
✗ DON'T over-engineer → patterns add abstraction/indirection; if you don't NEED it,
it's complexity for nothing
✗ Avoid premature abstraction → don't build flexibility you don't (yet) need (YAGNI)
✗ A simple, direct solution is often BETTER than a pattern-heavy one
→ over-using patterns makes code MORE complex and HARDER to understand (the opposite goal)
