6.2 Simple Design
If you knew nothing whatsoever about design, you might consider following three simple rules when practicing TDD.
-
Ensure your code is always highly readable and expressive.
-
Eliminate all duplication, as long as doing so doesn’t interfere with the first rule.
-
Ensure that you don’t introduce unnecessary complexity into your system. Avoid speculative constructs (“I just know we’re gonna have to support many-to-many someday”) and abstractions that don’t add to your system’s expressiveness.
The final rule is important, but the other two hold slightly higher priority. In other words, prefer introducing an abstraction such as a new member function or class if it improves expressiveness.
Following these rules can give you an eminently ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access