March 2015
Intermediate to advanced
236 pages
5h 26m
English
Any interesting problem has umpteen solutions. You choose a blue-ribbon winner, perhaps because it performs or smells better. That leaves the “loser” solutions available for cross-checking the production results. Maybe the runners-up are too slow or inflexible for production use, but they can help cross-check your winning choice, particularly if they’re trusted ‘n’ true.
We can use the “inferior” Java library implementation of square root to cross-check. (Apparently we suffer from bad egos.) We check whether or not our new superspiffy square-root logic produces the same results as Math.sqrt():
| iloveyouboss/15/test/scratch/NewtonTest.java | |
| | assertThat(Newton.squareRoot(1969.0), |
| | closeTo(Math.sqrt(1969.0), ... |
Read now
Unlock full access