Pragmatic Unit Testing in Java 8 with JUnit by Jeff Langr

Pragmatic Unit Testing in Java 8 with JUnit by Jeff Langr

Author:Jeff Langr
Language: eng
Format: epub
Tags: Pragmatic Bookshelf
ISBN: 978-1-94122-259-1
Publisher: The Pragmatic Bookshelf, LLC


Finding Better Homes for Our Methods

Our loop is a bit easier to read—great! But we note that 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 matches() method to the Criterion class. Criterion objects already know about Answer objects, but the converse is not true—Answer is not dependent on Criterion. If you were to move matches() to Answer, you’d have a bidirectional dependency. Not cool.

Here’s matches() in its new home:

iloveyouboss/18/src/iloveyouboss/Criterion.java

​ ​public​ ​class​ Criterion ​implements​ Scoreable {



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.