Finding Better Homes for Our Methods
Explore how to refactor Java unit tests by moving methods to more appropriate classes, reducing dependencies, and applying the Law of Demeter. Understand the use of temporary variables to clarify code intent and enhance test readability.
We'll cover the following...
We'll cover the following...
Our loop is a bit easier to read now, but the newly extracted code in matches() doesn’t have anything to do with the Profile object itself. It seems that either the Answer class or the Criterion class could be responsible for determining when one matches another.
Move the newly extracted ...