Ayende @ Rahien

It's a girl

Use the right tool for the job

Roy is talking about certain dogmatic approaches in the ALT.Net community with regards to Type Mock. Go and read the comments, the thread is far more interesting than just the post.

Now that you have done so, let me try to explain my own thinking about this.

Type Mock has the reputation of supporting unmaintainable practices. You can argue if this reputation is accurate or not, but it is there. In fact, from Type Mock's own homepage:

Saves time by eliminating code refactoring and rewriting just to make it testable

Here is the deal, I don't think that you should eliminate code refactoring. I think that avoiding dealing with technical debt is a losing proposition in the long term.

Certainly Type Mock enables me to ignore highly coupled design and still be able to create tests for it.

Is this of value? Absolutely!

Is this desirable? I don't believe so.

Can I use Type Mock to create software with decoupled, testable design? Of course I can.

But then there is the question: what do I get from Type Mock?

Quite a lot of other goodies, actually:

  • Integration with the IDE
  • Understanding debugger func-eval (and evil feature which can cause no end of pain when doing mocking)
  • Visual Mock Tracer
  • Other things that I am not aware of because I am not a Type Mock user

The question whatever you should use it or not depends on your situation, as the author of Rhino Mocks, I don't think that I can give an unbiased opinion.

Comments

Roger Alsing
05/19/2008 08:14 PM by
Roger Alsing

"Here is the deal, I don't think that you should eliminate code refactoring"

Incase you don't already have any tests, then you don't want to do much refactoring in fear of breaking the existing code.

So by allowing testing w/o change, you can start writing tests directly.

Those new tests will then allow you to start refactor your code w/o having to worry about breaking anything.

So this approach could allow you to get a refactored testable codebase faster than if you would have to start refactoring upfront.

Just my 2 cents..

Jeremy Gray
05/20/2008 01:01 AM by
Jeremy Gray

@Roger - the only thing you need to refactor code that doesn't have tests is some combination of the following (optimally all three, but certainly not a necessity): another pair of eyeballs, a modicum of common sense, and/or a minimum degree of caution. You certainly don't need to bring tools like TypeMock to the table to get the job done.

This may sound harsh, but here's the thing I see TypeMock used to make more than anything else: excuses. Excuses of all sorts, but primarily excuses for not making concerted efforts to improve the design (and therefore the maintainability among a million other things) of existing code.

Comments have been closed on this topic.