typemismatch

just a projection of my own imagination

  • You are here: 
  • Home
  • A warning about test driven development

A warning about test driven development

Posted on June 1st, 2009

Oh wow did someone really say something bad about TDD … I mean what could be bad about this latest fad ;-)

So testing your code is of course a good thing. Anything these days to help us write better code is a good thing but definitely in moderation. I’d say with all the work going into TDD and I’ll later explain my thoughts on DDD, people are once again on the search for the holy grail of software engineering. It doesn’t exist, get over it – software engineers are artisans by definition and that is because our skill is extremely creative and you can’t wrap it up in a process to make it perfect.

What bothers me with TDD is the amount of effort being placed on “passing the test”. It is one thing to make your code easier to test but a totally different thing to engineer your entire application, just so it can be tested. Is your client paying you $$ per hour to have something that can be tested or something that works?

What about dependency injection. A hot subject for allowing the injection of mock objects or testable objects into code. My question is, if you inject a mock object into a test – is the test really real? Now inversion of control has its place, like most patterns, but I warn you against thinking you’ll now have perfect code if every class is instantiated through an IoC container.

So when it comes to application architecture I urge you to use some common sense. Pick patterns that solve problems you really have. A lot of code can be tested just fine without DI. A facade is often simpler for centralized code. Here are the general rules I would suggest to keep you on track:

  1. Build an application that meets the requirements first!
  2. Make sure it performs and scales well.
  3. Make it easier to test! but not a requirement if it means major architectural changes.
  4. If you can’t automate your test, like many user interfaces – use a person, they’re called QAEs!

You don’t have to like it but too many developers forget what the point of the code is to start with. Not to pass tests but to do something cool :)

  • Audomate

Tags:
Filed under Software |

One Response to “A warning about test driven development”

  1. typemismatch – My TDD Analogy Says:
    June 3rd, 2009 at 9:59 pm

    [...] my post about Test Driven Design I expressed concerns around building your entire architecture to just support testing. My thoughts [...]

Leave a Reply