Object test bench rocks!

You ever get that feeling when you stumble across something truly mind-blowing and you want to blog about it instantly? You feel that you need to just tell someone how cool something is? Well, I've just had such an experience and the cause is a new Visual Studio feature called Object Test Bench.

Though I'm a pretty hard core Visual Studio user, there are always new features that I keep discovering, especially in Whidbey. I've been hacking away at a prototype of an idea I've had when all of a sudden, I had a problem which a lot of us run into.

 I had a bunch of code which I wanted to try and execute and test. However, the way my program worked, I had to write a bunch of other code to load data and feed it into the code I had finished writing. Let's call the method I have finished writing FooBar (in reality, it is a bunch of methods).

I could lay out the data structures by hand but that would prove painful. Also, since this was a Winforms project, I would be writing a lot of code just to be able to *test* my code. I was about to start typing out code to layout the data structures necessary for FooBar to work when I suddenly remembered a series of blog posts from Partha about Object Test Bench (start here - he has put up screenshots as well). I opened up his blog post and started digging around. Within 10 minutes, I was shaking my head in disbelief. I am truly blown away!

Object Test Bench is a new feature in Visual Studio 2005 which lets you visually execute code and play around with objects (read Partha's blog for a better and funnier description :-) ). Such tools have existed for other languages before (the Lisp REPL was probably the predecessor for all these tools) but in terms of Microsoft development tools, this is truly a first.

Here are the key OTB features which I've stumbled on in the last 2 hours  (see Partha's blog and MSDN for the full list of groovy things you can do)

  • Construct objects and execute code visually. You can right click on a class and say 'Create Instance' and right click on an instance and invoke one of its methods
  • This visual execution of code has full debugging support - you can hit breakpoints while you're invoking a method from the GUI, for example.
  • OTB ties in with the immediate window. So if you're tired of the right-clicking and invoking methods, you can type in code to execute inside the immediate window, just as you would do inside a Lisp/Scheme REPL.

Though this tool seems to be primarily aimed at exploring APIs and at academia, I'm already calculating the hours and hours of time I'll save by using this tool. I've probably saved a couple of hours already!

Some really cool people are writing C# REPLs but what caught me by surprise is that VS now packs a REPL - with turbo-chargers!

Enough gushing and back to work. :-)