良いクラスモデリングとは、実際のドメイン概念にマップするクラスであり、それぞれが1つの明確な責任を持ち、正直なis-a/has-a関係を通じて関連付けられ、境界での抽象化に依存しているということです。公式はありませんが、繰り返し可能なプロセスがあります。
実践的なプロセス
text
1. Find the NOUNS → candidate classes (Order, Customer, Payment)
2. Find the VERBS → candidate behaviors/methods (place, refund, ship)
3. Assign each behavior to the class that OWNS the data it needs (high cohesion)
4. Choose relationships: IS-A (rare, must pass LSP) vs HAS-A (default)
5. Depend on interfaces at boundaries (DIP); inject volatile dependencies
6. Keep invariants inside the object (encapsulation); prefer immutability for values
