🧠 Engineering Culture

OCPの大きな誤解:未来を予測するのをやめろ

オープンクローズド原則? 超能力プログラミングじゃない。ジョン・スキートが誇張をバッサリ——拡張可能なSwiftを罪悪感なしで構築し直す時です。

Swiftコードでプロトコルを使った悪いOCP実装と良いOCP実装を示す図

⚡ Key Takeaways

  • OCPは「一切の修正禁止」ではない——変更に対する安定した境界を設定することです。
  • Swiftではプロトコルを使って決済や図形などの変動を分離します。
  • Protected VariationsのほうがOCPの表現より優れています。実際の現在の変動を予測せよ。
Published by

DevTools Feed

Ship faster. Build smarter.

Worth sharing?

Get the best Developer Tools stories of the week in your inbox — no noise, no spam.

Originally reported by dev.to

Stay in the loop

The week's most important stories from DevTools Feed, delivered once a week.