Ayende @ Rahien

My name is Oren Eini
Founder of Hibernating Rhinos LTD and RavenDB.
You can reach me by phone or email:


+972 52-548-6969

, @ Q c

Posts: 6,026 | Comments: 44,842

filter by tags archive

It depends on what you are optimizing for…

time to read 1 min | 188 words

Today I was writing this code:

public class FakeRandomValueGenerator : IRandomValueGenerator
    private readonly int valueToReturn;

    public FakeRandomValueGenerator(int valueToReturn)
        this.valueToReturn = valueToReturn;

    public int Next(int min, int max)
        return valueToReturn;

This caused some concern to my pair, who asked me why I was hand rolling a stub instead of using a mocking framework. My answer was simple.

It will take me less time to write the class than it would take me to bring up the Add Reference dialog.



Too true!

I typically schedule my reference adding around getting a cup of coffee.

Jim Greco

How about....

public class RandNum


public Func

<int RandFunc { get; set; }

public int Next(int min, int max)


    return RandFunc != null ? RandFunc() : Random.Next(min, max);



syntax may be horribly off :)

junior programmer

doesn't this mean we should ditch visual studio for something more lightweight and faster

unfortunately m$ always try to bundle everything into one product and try to generate everything on the fly

i still prefer not to use IDE

i prefer things like textmate, vim, etc


LOL. Awesome.

Jacob Stanley

If only IRandomValueGenerator were a delegate instead of an interface:

int random = 6;

var c = new ClassThatNeedsRandomValues((min, max) => random);


You've become complete freak man!! This is good.


If this is the only stub you need, makes sense. Otherwise, not.


Add Reference dialog is so slow !!!! that I was thinking why don't put four options outside:

-Add Project Reference

-Add File Reference

-Add Gac Reference

-Add Com Reference

The last two are the slow ones.

¿thougs? HEY? Someone that want to put a LADY-BUG

Will Smith

R# is pretty good about adding new references for you without having to open the "Add Reference" dialog.

Stefan Steinegger

I always have two or three instances of visual studio running at the same time. If one is compiling, running tests, blocked for no reason or about to crash, I'm working with the other one on something else. In other words, I'm switching every few minutes. :-/

Yes, I'm also an impatient person.

Patrik H&#228;gne

I did the exact same thing (well it was a different interface) for the exact same reason a couple of days ago. To my dismay I had to do something else in another test a couple of minutes later that forced me to go and add the reference anyway.

Chris Smith

Use it as a couple of minutes to chill out and find something interesting to listen to...

Or do what I did and rewrite everything so it builds in nant straight out of SVN with just the SDK on the box. There are SO many problems relying on Visual Studio for even basic tasks sometimes.

Comment preview

Comments have been closed on this topic.


No future posts left, oh my!


  1. Technical observations from my wife (3):
    13 Nov 2015 - Production issues
  2. Production postmortem (13):
    13 Nov 2015 - The case of the “it is slow on that machine (only)”
  3. Speaking (5):
    09 Nov 2015 - Community talk in Kiev, Ukraine–What does it take to be a good developer
  4. Find the bug (5):
    11 Sep 2015 - The concurrent memory buster
  5. Buffer allocation strategies (3):
    09 Sep 2015 - Bad usage patterns
View all series


Main feed Feed Stats
Comments feed   Comments Feed Stats