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

ayende@ayende.com

+972 52-548-6969

, @ Q c

Posts: 5,940 | Comments: 44,405

Copyright (C) Ayende Rahien 2004 - 2015

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.


Comments

James

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

jdn
jdn

LOL. Awesome.

Jacob Stanley

If only IRandomValueGenerator were a delegate instead of an interface:

int random = 6;

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

Thamil

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

dave

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

Jose

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.

Comments have been closed on this topic.

FUTURE POSTS

No future posts left, oh my!

RECENT SERIES

  1. Challenge (45):
    28 Apr 2015 - What is the meaning of this change?
  2. Interview question (2):
    30 Mar 2015 - fix the index
  3. Excerpts from the RavenDB Performance team report (20):
    20 Feb 2015 - Optimizing Compare – The circle of life (a post-mortem)
  4. Large scale distributed consensus approaches (4):
    24 Nov 2014 - Concurrent consistent decisions
  5. Modeling exercise (3):
    28 Oct 2014 - The grocery store’s checkout model process approach
View all series

Syndication

Main feed Feed Stats
Comments feed   Comments Feed Stats