📎 Webclip
SOLID Code for SOLID Reasons
Good code should be written because it is easy to maintain, not mainly because it is easy to unit test. The post treats testability as a helpful effect of good design, then links that design to SOLID principles, bounded contexts, and anti-corruption layers.
Reading notes#
- Good code is easy to maintain, and that is the main reason to write it.
- SOLID is presented as a useful starting point for OO code, along with bounded contexts and anti-corruption layers from Domain Driven Design.
- Bounded contexts separate the main code base from external systems, and anti-corruption layers keep one context from leaking into another.
- Small classes are justified by coupling and maintainability problems, not by isolated unit tests or private method testing.
- Dependencies should point to abstractions rather than concretions because this reduces coupling and makes change safer.
- Wrapping third-party dependencies in adapters isolates the code from external change and from mismatched principles.
- The post argues that “it makes it unit testable” should not be the main defense for design choices.
- TDD is described as a way to reveal violations of design principles.
- Moles or shims are criticized because they can hide poorly written code instead of exposing it.
- The author rejects using KISS and YAGNI to dismiss SOLID and context boundaries in legacy or complex cases.
