friendly-coins Rule #4: One Dot Per Line
When I embarked on this refactor, I hadn’t yet got to the point of minimizing the calls to the horrible WrappedInteger.intValue() method. What ended up happening is having a load of extra lines to assign the .intValue() to a temporary variable, subsequently used on the next line. Yuck. Not to worry, that got taken care of when I improved the WrappedInteger() later.
There were also some egregious offenders which went beyond the simple intValue() gaff. A nice examples below:
BEFORE:
while( index >= 0 && ordered.get(index).intValue() >
total.intValue() - ret.sum().intValue() ) {
AFTER:
while( index >= 0 &&
greaterThan( ordered.get( index ), maxAddable) ) {
Aside from that there were some required uses of temporary variables (below). Precious few “real” encapsulation examples, so I seem to not have been a huge offender on Demeter’s law. Not this time around at least …
BEFORE:
return this.getClass().getSimpleName() + "<" +
Helpers.stringJoin( getCoinSets(), Joiner.COMMA ) + ">";
AFTER:
final String className = klass.getSimpleName();
return className + "<" +
Helpers.stringJoin( getCoinSets(), COMMA ) + ">";
