March 2015
Intermediate to advanced
236 pages
5h 26m
English
In Profile, we scrutinize the matches() method:
| iloveyouboss/big-2/src/iloveyouboss/Profile.java | |
| | public boolean matches(Criteria criteria) { |
| | MatchSet matchSet = new MatchSet(answers, criteria); |
| | score = matchSet.getScore(); |
| | return matchSet.matches(); |
| | } |
It has the awkward side effect of storing a calculated score on the Profile object. That makes no sense from the context of a Profile. A Profile doesn’t have a single score; it only has a score in conjunction with an attempt to match on criteria.
The score side effect causes another problem, which is that we can’t separate one interest from the other. If we want the score, we have to know to call the matches() method, which is counterintuitive, and we ...
Read now
Unlock full access