TypeMock is Freedom

Oren has answered my Quiz, by saying that

using(TextWriter writer = IoC.Resolve<IFileWriterFactory>().Create(filename)) writer.Write(text);

is easier to maintain! Well I cannot argue with that. Oren is one of a kind and I am sure that he can swallow these IoC containers and maintain them in his sleep. But would you have chosen this path if you didn’t need to test the code? Probably not.

We know that easy to understanding code makes the code maintainable, not only to developers who haven’t written the code but also the the developer who wrote the code 3 or more months beforehand.

but I think that using it [TypeMock] to enable brute force testing is harming the design process

Using TypeMock gives you Freedom. It gives you total freedom to choose your design:

  • Freedom to choose When you want to design. Before/During or After writing implementation
  • Freedom to choose How you want to create new objects. Using the new keyword/ a Singleton/ Factory or IoC Container
  • Freedom to choose the Balance of your design. Flexibility/Extensibility/Maintainability/Cohesion/Just In Time Design (YAGNI)

You might be scared of this freedom, but it is not something new. We have always had this freedom until we had to nUnit test our code. Then we lost this freedom and had to find different constraining techniques. It might make our code better, but it might not. I personally like my freedom.

2 comments
  1. Eli,

    you’ve gone from “stop DFT!” to freedom.

    A softer and more sensible stance, it seems, as opposed to the (silly) “stop DFT!” demonstration call.

    You write “if you didn’t have to test”. What code don’t you have to test – at all, in any form?

    I have *never* written any code that I did not have to test – whether it be *manually* using a console app, or a quick coded test that I can reuse.

  2. Mawi,
    Both stances are different facets of the same idea.
    Once you have the Freedom to Design as you wish without bending over (or better worded, without turning inside out) to make it testable, You will stop DFT.
    Did you know that the number 1 reason that many developers stop writing unit tests is that they don’t what to change the design.

    Did you know that they feel restricted that they HAVE to design using IoC, even if they didn’t really need it.

    Sure, you *must* test your code.
    But you don’t have to DFT in order to do it.

Add Comment

Required fields are marked *. Your email address will not be published.