Object-Oriented Design — Middle¶
High cohesion keeps related behavior together; low coupling limits knowledge between collaborators. Connascence asks what must change together and how strongly. Keep strong forms local and prefer weaker forms across boundaries.
Use SOLID diagnostically:
- SRP: one coherent reason to change;
- OCP: stable variation points, not speculative extension;
- LSP: substitutions preserve caller expectations;
- ISP: consumers depend on focused capabilities;
- DIP: policy does not depend directly on volatile detail.
Apply tell-don’t-ask, command-query separation, and the Law of Demeter to reduce navigation and external decision logic. Watch for feature envy, primitive obsession, data clumps, god classes, and shotgun surgery.
Test yourself¶
- Which change reason reveals low cohesion?
- How can an implementation violate LSP?
- Where should an interface be owned?
- What navigation chain reveals missing responsibility?
Continue to senior.md.