Brian Di Croce

Passionate about developing and delivering better software with .NET

Subscribe in a readerSubscribe in a reader Subscribe via emailSubscribe via email

For if you love those who love you, what reward do you have? Do not even the tax collectors do the same? And if you greet only your brothers, what more are you doing than others? Do not even the Gentiles do the same? You therefore must be perfect, as your heavenly Father is perfect. (Matthew 5:46-48, NIV)

Mar
14
2008

Three Index Cards To Easily Remember The Essence Of Test-Driven Development

As I was reading a couple of ObjectMentor’s blog posts, one of them caught my attention.  It was Tim Ottinger’s post on “TDD on Three Index Cards“.  He recalls how someone missed part of a class he was teaching on TDD and told that individual the fundamental essence of TDD on three index cards in less than 15 minutes.  After reading that, I got myself thinking “Hhhmm…not a bad idea! I wonder if it’s physically possible?“. 

Ten minutes later, I’m at Staples buying some index cards and a couple of markers (for pictures purposes…of course…).  Here’s the final product which every credit goes to Tim for this very simple, practical and useful idea.  Kudos to my wife for taking the pictures.

Here’s a recap of the main ideas behind TDD (full credits goes to Tim):

Card #1. Uncle Bob’s Three Laws

  • Write no production code except to pass a failing test.
  • Write only enough of a test to demonstrate a failure.
  • Write only enough production code to pass the test.


Card #1: Uncle Bob's Three Laws 

Card #2: FIRST Principles

  • Fast: Mind-numbingly fast, as in hundreds or thousands per second.
  • Isolated: The test isolates a fault clearly.
  • Repeatable: I can run it repeatedly and it will pass or fail the same way each time.
  • Self-verifying: The Test is unambiguously pass-fail.
  • Timely: Produced in lockstep with tiny code changes.


Card #2: F.I.R.S.T Principles

Card #3: Core of TDD

  • Red: test fails
  • Green: test passes
  • Refactor: clean code and tests


Card #3: Core of TDD
By the way, if you’re in the Montreal/Quebec sector and you’d like (or perhaps your team) to know more about TDD (unit testing best practices, patterns of unit testing, introduction to Mock Objects, etc.), I highly recommend taking the two-day Test-Driven Development in .NET training course with us at the CRIM. 

kick it on DotNetKicks.com

Similar posts you might be interested in reading:

3 Responses to “Three Index Cards To Easily Remember The Essence Of Test-Driven Development”

  1. Tim Says:

    I wish I’d posted the cards. Ah, there is not always a camera around when I need one.

    You should see mine on Scrumming on two cards. :-)

  2. Brian Di Croce Says:

    Tim,
    Ha! Don’t tell me one of the cards shows a pig and a chicken having breakfast at some bar! ;)

  3. DO Says:

    If Dijkstra was looking over Uncle Bob’s shoulders he might tell him to add Card #0 for proof driven development, to prove the solution to yourself before implementing said solution with TDD.

Leave a Reply