March 2015
Intermediate to advanced
236 pages
5h 26m
English
In our case, the answer local variable doesn’t clarify the code, and it’s used only once. Inline (remove) the variable by replacing its use with the answerMatching(criterion) expression:
| iloveyouboss/20/src/iloveyouboss/Profile.java | |
| | for (Criterion criterion: criteria) { |
* | boolean match = criterion.matches(answerMatching(criterion)); |
| | |
| | if (!match && criterion.getWeight() == Weight.MustMatch) { |
| | kill = true; |
| | } |
| | if (match) { |
| | score += criterion.getWeight().getValue(); |
| | } |
| | anyMatches |= match; |
| | } |
You could manually inline answer, but your IDE most likely automates the inline refactoring. In Eclipse, select Refactor ▶ Inline… from the main menu to inline.
The very existence of automated IDE automated ...
Read now
Unlock full access