The art of development driven testing (DDT)

This is a post about nothing really. This post probably won’t make you any wiser. It won’t help you pay your debts. It won’t help you get a boyfriend (or a girlfriend) but it might waste some five minutes of your life. So if you have something productive to do, please go back to doing it. Anyhow, I have been writing so much code lately and almost forgotten how good it feels to write something other than code.

Back to DDT. Well, what the heck is that? DDT is what many beginning developers call TDD. The TLDR of TDD is initially writing a bunch of tests that will fail (because there is no code)and then writing code that passes those tests. So if you have a function you want to write, you first write some tests to test the function then write the function that will pass the tests.

Unfortunately, many noobs (of which I am one), rush to write the code first, then once they are done with the functionality, start writing tests for the code (sounds familiar?). Once done, they pat themselves on the back (is that even possible?) and say they have done TDD. No, that is not TDD, that’s DDT. In TDD, your code should be driven by the tests you write. In DDT, your tests are driven by the code you write. I don’t think there’s anything bad with DDT. The problem comes when you do DDT and deceive yourself into thinking you have done TDD.

Don’t let my tone deceive you that I am any better. I have and still write bad code (though my code is sucking less day by day). I have written large blobs of code without tests (gasp). The kind that would make Linus Torvalds switch to Windows, or make Miley Cyrus stop twerking (is that even possible?). Ever since I learnt about TDD a couple months ago (thanks to Andela), I have being trying to practice it. But old habits die hard. So first instinct is to always dive into the code and then write tests later. I’m trying to do more TDD and less DTT but haven’t perfected that yet. I think i’ll get there someday not so long from now. The goal is to use TDD in 100 % of the projects I do.

If you’re reading this, it’s too late (see what I did there?). Please get back to whatever you were doing before, unless it’s DDT.