Red Light, Green Light: Testing & the Art of Failure

I’d like to discuss something that has intimidated and embarrassed me since I first showed my code to a professional:


Fortunately, the Advanced Beginner Challenge includes a link to Harry Percival’s Test-Driven Development with Python. Better yet, it’s free to read online.


Developed by Kent Beck, the originator of Extreme ProgrammingTest-Driven Development starts with testing. Whereas many developers would rather postpone the “boring” work of testing as long as possible, TDD models code from the outset. In TDD, you write a test that fails in a way you expect, then you code just enough to solve that problem. Then, you ensure the test passes and go on to the next test.

In fact, TDD expects failure. Percival proposes a heuristic: Red Light-Green Light-Refactor. Write a test that is supposed to fail, write code to get the test to pass, and then refactor code.

It seems a little ass-backward and heavy-handed. But a methodology that works from the ground up makes a lot of sense if you consider the challenges of the alternative.

Errors are inevitable in writing code — I respect a way of working that depends on them.

Failure in Art

What if I’d learned how to manage failure in my music education? What if this kind of working could be in some way adopted by the musical theater writing community? As it stands, the opportunities for musical theater writers are few and far between. And the ones that exist require so much money, failure isn’t really an option.

Of course, it’s a little out-of-domain to look for a corollary to exception handling in the art of collaboration. But I bet the cultural underpinnings of perfectionism in art and science are similar.

Could that be why so many musicians turn out to be well suited for work as programmers?