Chapter 9Bigger Design Issues

In the last chapter we refactored the matches() method into a number of clearer, more-composed methods. Such continual refactoring of small bits of code helps to keep code maintenance costs low.

Writing unit tests isn’t an exercise that occurs in a vacuum. It’s instead part of the larger, continually shifting puzzle we call design. Our system’s design impacts our ability to write tests, and vice versa.

In this chapter we’ll take a look at some bigger design concerns. Specifically, we’ll focus on the Single Responsibility Principle (SRP), which guides us to small classes that increase flexibility and ease of testing, among other things. And we’ll investigate command-query separation, which uses methods that don’t ...

Get Pragmatic Unit Testing in Java 8 with JUnit now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.