David Sachdev wrote:Do you feel that Test First development lets you strategically architect out what you are trying to develop, or do you find it limiting?
I'll share my thoughts on this. First of all, I don't see TDD as a strategic way to architect a solution but more like a way to help me be systematic and focused. Working test-first definitely helps me produce working designs that are modular and fit for purpose. What it limits, for me, is the unwanted things like spending two hours to create a design that's so-and-so.
J.B. Rainsberger makes a nice analogy between TDD and the brakes in your car. He says you don't have brakes in your car so that you can stop. Instead, you have brakes in your car so that you can drive fast. The point is that TDD makes you think about what you're doing and while it may feel like you're going slow because you need to write all those tests, it's the very presence of those tests that allows you to keep writing code as fast as you are. Without the tests and the thinking that leads to those tests, you'd spend a lot of time reading the code over "one more time", "just to be sure" that you haven't broken anything and aren't about to break anything.
TDD is also definitely not the only way to get that outcome and I don't test-drive my code 100% of the time. For instance, writing a test upfront requires the ability to imagine a design that would work. If I'm integrating with an API I don't know, how could I imagine a valid, working design? In such situations, I tend to first hack around with the purpose of
learning what I want and then either 1) backtracking a bit and test-driving the code (now that I know how the API works), or 2) adding tests around the hacked-together prototype. When I end up doing the latter, I almost always end up regretting that I didn't test-drive it from scratch. I still do it every now and then. How stupid of me...
By the way, when you say this:
David Sachdev wrote:I find that I prefer to test simultaneous with development as opposed to a test-first approach.
What do you mean by "simultaneously" testing and developing? To me, writing one test, making it pass, writing another, making that pass, etc. is already quite simultaneous and without clear checkpoints along the way I don't feel like I know where I am.