March 2015
Intermediate to advanced
236 pages
5h 26m
English
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 { |
| | // ... |
| | public |
Read now
Unlock full access