Posts
833
Comments
691
Trackbacks
1
<< ASP.NET: DropDownList SelectedIndexChanged Not Firing in User Controls | Home | Bizarre Foods >>
Refactoring at work

I've started to really dive deep(er) into mock objects.  I'm still highly skeptical about them (for reasons I won't go into here), but I am testing out Rhino Mocks for a project.

As such, I finally got around to watching Ayende's webcast introduction of it.

He starts off by noting that he is not a native English speaker, that he has a thick accent, etc. etc. etc. but I never had a moment of difficulty understanding him.  The fact that he isn't a native English speaker means he was consciously aware of what he was saying, which led to a few funny comments, such as: "I am explicitly expecting no exception...What a stupid sentence", but all of that is normal.

If you've ever heard a taped play-back of a conversation you've had, you have almost undoubtedly sounded a lot worse (this is why prosecutors sometimes have problems with wiretap cases....you aren't aware of how 'incomprehensible' normal speech is (which relies on visual cues, hand gestures, context, etc.) when read out loud).

Watching the web cast, a few things were very clear:

1) This is not an introductory webcast for people new to mocking objects.  It is an introductory webcast for people who are familiar with other mocking frameworks.  If you didn't have any context for what mocks are about, you would be very confused.  He does give an introduction of what he is going to be talking about, and why mocks are useful, but the actual presentation is not '101' level material.

2) I guess this goes without saying, but you can tell that he *really* knows what the fuck he is talking about.  I mean, one would hope he would know how Rhino Mocks works, and that's obvious, but the side-comments along the lines of "Well, I needed to do this because the compiler complained" just indicates his deep knowledge of all sorts of things.

3) I'm still highly skeptical of mock objects.  Little from the webcast changed that, but, to be fair, it takes a *really* good webcast to change a mindset.

4) The most I 'learned' was watching a very, very highly trained developer refactor live.  I understood the changes he was making (I think) as he made them, and just seeing them live made me realize how far I have to go in that area.  You could see why certain coding styles are so tied into tools like ReSharper, and why some think Microsoft's Entity Framework gets in the way.

I don't think I'll watch it again.  Well, I don't think i'll watch it again unless I become less skeptical of mocks and/or need to mock SMS, but it's a good view.

posted on Sunday, May 13, 2007 8:03 PM
Comments
Gravatar
# re: Refactoring at work
Paul
5/14/2007 10:18 AM
"I've started to really dive deep(er) into mock objects. I'm still highly skeptical about them (for reasons I won't go into here)"

How about elaborating your thoughts on this in a follow up blog post?
Gravatar
# re: Refactoring at work
jdn
5/14/2007 10:51 PM
Thanks for the suggestion. I've thought about it, and will try to think about how to write something about that.

There's a simple difficulty, of course: it's hard to write a short post on that. I'll give an example to try to be a little clearer.

One obvious case of where you might try to use mocks is when you want to mock the result of a database call without actually calling a database (it might be down, you might be disconnected, it might be Tuesday...all sorts of reasons why it might not be available).

Makes sense. So you create a mock to return whatever it is the database was going to actually return.

An obvious question arises: over time, how do you know that your mock accurately represents what the database would actually return? What if the schema of the database objects change? You have to make sure the mocks reflect those changes. Easy enough in one case, but there is never just one case, especially over time.

To me, unit tests need to give you comfort that your code will work in an actual production environment. Anyone who has used mocks will probably immediately respond "that's what integration tests are for." Which is an intelligent response.

But not actually correct.

Explaining why is difficult to do.

If I can come up with a good example that would help. I'll see what I can do.

Thanks for the feedback.

Post Comment

Title *
Name *
Email
Url
Comment *  
Please add 4 and 1 and type the answer here: