Breaking concepts down into logical chunks, tackling them in isolation. Sound familiar? This is how we write tests, but it’s also how a mathematician writes proofs. Exploring the similarities and differences between the two can bring us back to our profession’s mathematical roots.
This looks at mathematical proofs and ruby code side-by-side in an effort to uncover why these sorts of puzzles are appealing. It explains a few mathematical methods through Ruby code, but don’t worry, no math background is required. We will examine summation notation—the mathematical loop, as well as the multiple ways of defining the Binomial Coefficient. After that, we will translate a basic proof by induction into pseudo-RSpec in order to highlight the similarities between writing a test and writing a proof, such as the existence of stubs. Get a better understanding of what you love about test driving and perhaps learn some math in the process.