Toxic Elephant

Don't bury it in your back yard!

The Beauty of Git

Posted by matijs 10/11/2007 at 18h57

After my struggles with svk, working with git is a breath of fresh air. It has great support for branching and merging, and putting even the smallest of throwaway projects under version control becomes as simple as:

git init

Gone are the days of the “oh i’ll just make ten copies of this script here because setting up a repository takes too long” style of version control.

Tags no comments no trackbacks

I'm Not a Mockist

Posted by matijs 04/11/2007 at 13h56

Let’s talk about mocking.

It apparently is the hot new thing in Rails land. And like earlier silver bullets, it’s becoming a religion: Acolytes would rather write ten lines to set up a mock object than one to instantiate an actual one.

Honestly, I have tried to understand the benefits of mocking, but I just don’t see them1. Then I thought I would have to write a long article about how mocking is flawed, and would you people please all see sense already. Luckily, Martin Fowler did it for me, and with a lot more objectivity. Go read his Mocks Aren’t Stubs. In addition to explaining the difference between Mocks and Stubs (a difference often overlooked by the religious), he explains why you might not want to use what he calls “mockist testing”.

So, in the spirit of religious tolerance, I can now say: I’m not a Mockist.

My particular reasons?

  • Mockist testing is not DRY: Each class’ behavior is now defined in its code, its unit tests, and each time it is mocked.
  • Mockist testing tests a particular implementation of behavior, making refactoring harder.
  • Mockist testing makes writing your tests more work, inviting you not to test.

Next time you find yourself complaining that setting up your mock objects is such a lot of work, ask yourself: “Am I a Mockist?”. Maybe you’re not.

1 Well, one minor benifit I can see that you can start writing and testing your views before having written your models. I never seem to want to do that anyway, though.

Tags no comments no trackbacks