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: 5,971 | Comments: 44,508

filter by tags archive

It depends on what you are optimizing for…

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.


  1. Paying the rent online - 2 days from now

There are posts all the way to Aug 03, 2015


  1. Production postmortem (5):
    29 Jul 2015 - The evil licensing code
  2. Career planning (6):
    24 Jul 2015 - The immortal choices aren't
  3. API Design (7):
    20 Jul 2015 - We’ll let the users sort it out
  4. What is new in RavenDB 3.5 (3):
    15 Jul 2015 - Exploring data in the dark
  5. The RavenDB Comic Strip (3):
    28 May 2015 - Part III – High availability & sleeping soundly
View all series


Main feed Feed Stats
Comments feed   Comments Feed Stats