Design with Tests

Learn what code should do by analyzing through various tests.


Where one of our previous lessons, Insist on Correctness, focused on verifying that our code does what it’s supposed to do. In this lesson, we will focus on the meta-question, “What should this code do?”

On the surface, it might seem puzzling that a programmer would write code without knowing what it’s supposed to do ahead of time. Yet, we do it all the time. Faced with a problem, we charge off writing code and figure things out as we go. Programming is a creative act, not a mechanical one, and this process is akin to a painter charging off on a blank canvas without knowing exactly what the finished painting will look like.

Yet, programming also requires rigor. Testing gives us tools for both design and rigor at the same time.

Get hands-on with 1200+ tech skills courses.