matyb/roman-numerals

excessive implementation compared to testing

Opened this issue · 1 comments

matyb commented

commit 5fa2334 assumes that all roman numeral permutations are necessary. should have hardcoded return value of "I" to pass test, tested for 3 and while failing hardcoded 3 in implementation to pass test, and tested for next prescribed case and only then considered factoring into a map or data structures holding just necessary numerals for the tests required. adding all the conversion values in one checking was risky and could have allowed garbage or untested code to persist in the implementation. implementation did not evolve as fluidly as a non-presumptive pure tdd implementation should have.

matyb commented

No changing history, but I'd be glad to demonstrate I understand the implications of this mistake and how to "by the book" write code tests first. Rather than pasting in a dictionary of domain values, I should have teased that portion of the implementation out through red/green/refactor.

The proper cadence would be to:

  • hardcode "I" as a return value. this would pass the 1 test at the time.
  • add test for 3, and implement with case/conditional logic solution for I and III
  • add next prescribed test which included more numerals than I, and perhaps refactor the conditions into an associate array/map at that time but just for the values needed to pass that test
  • rinse and repeat doing the minimal amount of work to advance the implementation/test suite for each solitary rule/case