Palindrome checker is a better basic example of test-driven development

Photo by Filip Mroz on Unsplash

A commonly given basic example for test-driven development (TDD) is a function that is supposed to add up two integers. The stub always returns a specific number, like 0, instead of actually adding up its two parameters.

Of course that fails a test that expects something like 1 + 1 = 2. So you change the stub to return 2. But now that fails a…