Do I need a license to test-drive?

13 07 2010

I’ve spent the last few days writing tests then erasing them then writing them again. I’ve started, restarted and restarted so many times I could probably type most of the classes with my eyes closed. I should be frustrated by it all, I really should [to put it into perspective I think I wrote about 500 lines of code over the last couple of days and not one of them has been kept in the project]. But I’m not. Why?

I love learning. I really mean it, there is nothing I like more than doing something, getting it wrong then doing it again only better and really understanding the logic behind it.

I love coding. I really really do, I sometimes can write code for hours before even noticing that I’m hungry [many a-lunch do I eat cold].

I love coffee. I just, you know, love it. And nothing offers a better opportunity to slowly sip my coffee then programming.

But most of all I’ve got this itch, this little voice that tells me that understanding TDD, even just the bare-minimum at the moment, is of immense value. So I keep at it, throwing myself at the wall, trying over and over again. And I think that I’ve slowly come to understand some aspects of it and the reasons I’ve been missing the mark; assumption.

Never assume I’ve been told and have follow in life. Make sure, ask, document and design, never assume. Good advice but not for TDD, the way I see it anyway. I found it absolutely HARD to make assumptions about my code, to use/test it in advance. I kept falling back into writing the classes first, writing the bare functionality that I KNEW had to be there, and then write the tests. Each and every time I’ve over designed the system and wrote the objects in advance I ended up the same, changing the tests to match the code and getting locked up in complexity. It wasn’t TDD, it didn’t feel right.

3 days , 500 lines of code later [and who know how many deleted header/source files] and I’ve come to the conclusion that I should just bite the bullet and write the tests first. Write the #include in the test file, use namespaces without having them in place, declare and define objects which do not exist and just ignore the annoying little squiggles Visual Studio uses to tell me that something isn’t going to compile. Who cares, postpone writing code until you absolutely, positively have to.

Writing tests is still hard; there’s no magic to replace experience and I just need more of it [experience not magic]. But test-driving feels better now, it flows better and it shapes my code rather than the other way around. There’s still a long way to go with this project [which only started, luckily] but as long as I get to learn, code and drink coffee I guess I’ll be alright.

“Dreams aren’t broken here, they’re just walking with a limp”




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: