(yeah, I’m trying to start writing again, big woop, wanna fight about it?)
I was just musing on that weird early phase when you first create a new code tree and start doing minor exploratory hacking for an idea.
(musing is the perfect word for what this post is, as well.. don’t expect anything ground breaking; just me thinking out loud)
You don’t really have any complete units of functionality, so you don’t really want to commit it to a git repo (don’t want people to see the really early, stupid implementations); you don’t really want to start writing tests yet, because you know you’re going to throw most of these interfaces away an hour later anyway.
Minor aside: yes, I know, some of you write the tests before you even write the code. We disagree. I’m sorry.
You start to run the damn thing and dump out some output and start getting the results you want. You prune the code a little and get rid of some stupid glue. You move some functionality out to its own class or library or what-have-you. Things are working, your idea is starting to actually take shape.
The breaking point comes unexpectedly. You find a somewhat complicated, critical piece of logic that requires some refactoring. But now you’re worried – the code works as it is, or seems to, anyway. It’s time to write that test. It’s time to commit the existing code to a repo so that you have an audit trail of your refactor. All of a sudden, the project is starting to feel like a lot of work.
So am I wrong? Should I write the damn tests first like the TDD folks tell me?
Maybe. But I don’t think so. I think this blog post is ultimately about momentum. When you first start a fresh project based on an idea, you get on a roll quickly. You literally can’t write the code fast enough to keep all the ideas in your head. You’re cutting corners, sprinkling TODOs liberally for things that aren’t critical to just “get it working.” The problem with getting to that point where you have to start being responsible (“write ALL the tests!”) is that it saps you of that momentum.
My opinion, especially for personal projects, is that TDD robs you of that momentum before you’ve even started.
Uh oh, I’ve gone and made a statement about a religious engineering debate.
Ultimately, it comes down to commitment. Can you commit to doing the right thing, do you actually love this project that much? Is it worth spending your time polishing this thing instead of working on something else new and fun, or is it just going to end up being a polished turd?
In fact, this phase of a project is a lot like meeting someone you’re attracted to. Your gazes meet, 3 seconds pass, IT’S ON, nobody is thinking about tomorrow morning, it’s just all fun. Then a short amount of time passes and you realize, shit, I like where this is going, but how much?.. You start wondering if it’s worth passing up on repeating the previous 2 weeks with N others.. and shit, am I gonna have to shave my beard before I meet her mother? You have to decide if you’re going to commit.
(you see what I did there?)