Daniel Cazzulino's Blog : The myth that TDD or test-first slows you down is true

The myth that TDD or test-first slows you down is true

I'm sad to say it, but it is true. It slows you down. But not everytime, and not for everything. So let's be more specific on the cases where it DOES slow you down noticeably:

  • Cowboy or Duct Tape Programming Mode: If you code all day like crazy in a "cowboy" or "duct tape" programming mode, then it WILL slow you down, significantly. In this mode, you're hacking together stuff that works by pure luck, you're only superficially and typically manually "testing" the thing, before calling it "done" and move on. Someone will come after some day when the customer complains about a bug, and figure out what to do. Not your problem though, for sure. For all you care about, you might even have another job by then. Your productivity kicks ass, you're the fastest guy in the team, and can get "complete" features to your boss in record time. Everyone (who hasn't worked with you long enough) thinks you're a genious, 'cause you can get something that works on the first shot. Brilliant!

    It may also be just the way you are, and it's not that you don't care. It's just that your fingers fly and the itch to get the code done is SO strong that you just can't help it. Once I overheard an architect saying "I'm gonna tie your fingers with rubber bands!", hehe.

    TDD WILL SLOW YOU DOWN, A **LOT**.
  • Visual Studio Extensibility or Mobile Development: the red/green/refactor cycle is just so brutally slow that it's a real endurance test to try to keep doing TDD in many cases. Yes, you can isolate the IDE/Mobile environment, mock stuff here and there, but at the end of the day, the mock does not guarantee that things will actually work on the real thing. So you need to run tests on the actual environment more often than not. You'll spend a great deal of time trying to isolate slow areas, trying to write more code before you run just to avoid the slow turnaround (and then fixing multiple things in a single pass when multiple fail), etc. A total TDD-anti-climax for sure :(
  • TDD WILL SLOW YOU DOWN, **SIGNIFICANTLY**.

  • Show Customer Value, Quickly: there are some cases where the domain you're tackling is not very well explored, or the customer doesn't have a very clear idea of what to expect, or doesn't even believe you can deliver something valuable or innovative at all. In these cases, it's much more important to have a lot of tangible value/features soon, than to have little but very robust and well designed via TDD.
  • TDD WILL SLOW YOU DOWN, AND YOU MAY NOT HAVE A PROJECT AT ALL SOONER THAN LATER

 

Of these, the first one is one that requires careful attention and mentoring. Being a speedy programmer certainly is a good quality and an important one to being great, I think. There are times when you just need to be bloody fast and get the job done quickly (third case). Such a developer is invaluable in an organization. But he must understand the constraints of the current project. Getting rock-solid, maintainable and well-designed code might be much more important than raw amount of features/code.

The second and third cases are just a matter of setting the right expectations, and understand how you're going to approach development. In either, you might skip TDD altogether, or do it only in more complicated areas only. Or you might just have what you can as integration tests only.

 

And yes, being pragmatic is also a very good quality to have. Shipping is indeed a feature.

posted on Sunday, October 04, 2009 12:16 PM by kzu

# The myth that TDD or test-first slows you down is true @ Sunday, October 04, 2009 12:21 PM

I'm sad to say it, but it is true. It slows you down. But not everytime, and not for everything.

Anonymous

# re: The myth that TDD or test-first slows you down is true @ Sunday, October 04, 2009 1:24 PM

"Or you might just have what you can as integration tests only"
That is not enough especially when you are implementing base classes.

Fabio Maulo

# re: The myth that TDD or test-first slows you down is true @ Sunday, October 04, 2009 3:20 PM

TDD impacts all aspects of a project not just the writing of the code. Bugs that are not found and released can have a significant cost impact. TDD creates efficiencies in continuous testing and can have a positive impact on the structure & readibility of the code.
For sure, TDD will probably reduce your velocity at the begining and the rate of output for smaller projects. Also you may need to refactor existing code in order to do TDD.
From a project or product perspective there are positive gains in quality, finance, and customer relationship.

Dawn

# re: The myth that TDD or test-first slows you down is true @ Sunday, October 04, 2009 4:33 PM

I agree at most. We must wake up to the reality that TDD in actual projects can not exist in its pure form. Practicality, pragmatism, are necessary in most cases.

Samboy LIms

# speeds me up if anything @ Monday, October 05, 2009 1:46 AM

TDD means i make less stupid mistakes, and reduces the ammount of time i have to spend debugging (i love this).
It also works very well with pair programming, but i guess you also think that's a waste of resources?

Chris Bea

# re: The myth that TDD or test-first slows you down is true @ Monday, October 05, 2009 4:34 AM

Your list is not complete, and your post very much sounds like if you have the time/opportunity to TDD then don't you are 'duct-tape' or 'cowboy programmer' that doesn't care about the robustness and maintainability of your code.

It doesn't have to be all or nothing (a lot of people who are anti-TDD are still pro-Tests), you can still have all your code testable using 'TestAfter' and have high-level testable customer requirements with BDD and integration tests.

TDD is great for implementing adhoc feature-by-feature requirements (as done with most internal/enterprise software) however I find the bottom-up approach of TDD design compromises high-level top-down (e.g. SOA, messaging) architectures. I will be surprised to learn if any well thought out comprehensive high-level frameworks / architectures (e.g. the .NET Framework, WCF, WPF) were designed with TDD.

I find TDD'ing every class creates unnecessary friction and tests as much 'how your code works' as opposed to just testing 'what your code is meant to do' which adds overhead when you refactor and change your implementation.

Overall I think TDD is useful in some cases and will save time (feature-rich intranet apps, etc.) but overall goes against the pragmatic programmers GTD (Getting things done) approach.

Demis Bellot

# re: The myth that TDD or test-first slows you down is true @ Monday, October 05, 2009 1:19 PM

TDD, like any sort of process-oriented development, will slow anybody without a process down. The important distinction is that TDD as a process should provide value. Cowboy and duct tape programmers view process with suspicion, because such processes may provide little, no, or negative value to the software development lifecycle.

There are also certain .NET frameworks and class libraries that confound TDD by making it difficult to write isolated unit tests.

Joe Chung

# re: The myth that TDD or test-first slows you down is true @ Monday, October 05, 2009 2:43 PM

I tend to avoid TDD in the strictest sense but have adapted it to way I work. I need the freedom to be expressive at the start of a project so will not constrain my self to even writing good code. As soon as I have found the flow and inspiration and am on track with the designed features I start to have enough confidence to refactor the code into something better. When the refactoring slows down I then introduce adhoc tests mostly to prove the effectiveness of code. Its then at this point I introduce Unit tests which are the result of refactoring the initial adhoc tests. The end result of this process is very thin coverage of the emerging project. From then on the testing drives the development and the coverage increases incrementally.

David Champion

# re: The myth that TDD or test-first slows you down is true @ Monday, October 05, 2009 4:18 PM

To do real tdd on mobile is incredibly slow. The problem is that each time you want to test, the app has to be deployed to the device -- which can take minutes!

On Windows/Web testing, I can run through my entire test suite before the mobile tester even starts. Then if you need mocking you are on your own (doesn't exist right now -- like so many other things)

Chris Brandsma

# re: The myth that TDD or test-first slows you down is true @ Monday, October 05, 2009 7:28 PM

Chris Bea: I'm not arguing *any* of that. I'm a firm believer of all TDD values and have experienced first hand for years its benefits.

All I'm saying is that in some very specific cases (appropriately pointed out also by Chris Brandsma) doing TDD hurts so much that it can potentially put a project in risk 'cause you're failing to ship features fast enough.

To reiterate: it's NOT a failure of TDD, but of particular development/runtime environments that are very unfriendly to rapid feedback. Pairing on such an environment would indeed a significant waste of customer's money (two devs staring at the screen for 3-5 minutes on every test run while the mobile app is deployed to the device, etc. - multiply by # of test runs per day).

kzu

# Daily tech links for .net and related technologies - October 5-7, 2009 @ Tuesday, October 06, 2009 1:26 AM

Daily tech links for .net and related technologies - October 5-7, 2009 Web Development How To Speed Up

Anonymous

# re: The myth that TDD or test-first slows you down is true @ Tuesday, October 06, 2009 4:54 AM

Good luck trying to make do without TDD or only adopting it in a token manner. More TDD means less lines of production code written - as simple as that. That has always been my experience. A tighter code base that is more closely aligned with business requirements and less likely to undergo code rewrites and far easier to extend. That's because the point of TDD is generally missed - it's more of a design process than a mundane test function. Of course there are always time constraints and you have to be pragmatic, but can you really afford the time to takes to get code correct without TDD - in short it's a false economy - one you have to sell.

gavin

# re: The myth that TDD or test-first slows you down is true @ Tuesday, October 06, 2009 5:00 AM

To add. Agreed, it's difficult to introduce as it usually turns development on its head and it takes time. What any shop needs to do is bring in the very best people to jump start the drive towards full TDD. And if your shop cannot afford that try an find out in the community someone who can explain it.

gavin

# re: The myth that TDD or test-first slows you down is true @ Monday, October 12, 2009 6:33 PM

Always an interesting topic. From my point of view the arguments against TDD and unit testing in general have to do with wasting time or slowing the delivery of software. I am assuming that this relates to return on investment (ROI) which is important to the business. Testing though is more about cost of ownership (COI) which business does not realize until code needs to be extended or enhanced.

And since the additional overehead of dealing with larger volumes of defects or taking weeks longer to perform regression to ensure new code does not break existing features is a relatively slow bleed the business does not connect that the dots between faster, possibly lower quality, and the increased time to market for each additional feature it ultimately degrades the perception of the development group.

Developers should consider one thing, they are the experts in engineering software not the business.

I believe delivering a good design and well tested product up front drastically decreases the delivery time on all subsequent enhancements. Defects are found sooner, regression ensures continued quality and additional resources can be ramped up much sooner.

As for TDD specifically, the speed at which you wield it is no different than any other skill. The more you become comfortable with its use, the more natural it will become and the faster you will get. While there are exceptions to the practice, you should treat those as exception and not the rule.

Bill Woodson

# re: The myth that TDD or test-first slows you down is true @ Sunday, November 01, 2009 9:50 AM

[quote]I do believe people may use this those as an excuse not to do TDD. And you should not encourage that. It's irresponsible.[unquote]

kilfour