windows, gists comments edit

I’m a big fan of the “command prompt here” context menu extensions for Windows Explorer. I use them all the time. Sometimes, though, I need to go the other-way-around.

That is, I’m at a command prompt and I want Windows Explorer open at the current location of my prompt.

explorer %CD%

Pretty simple, but super helpful. I had one of those “man, I’m stupid”moments when I put two-and-two together on this.

I ended up making a little batch file “explore.bat” and stuck it in my path.

@echo off
echo Opening Explorer on %CD%
explorer %CD%

So now it’s just “explore” at the prompt and magic happens. (Yes, I do realize it’s only five characters shorter, but I also get a nice little echo message to tell me what’s going on, plus I don’t have to remember it anymore.)

Note you can get some slightly different functionality if you use some of the command line switches for Windows Explorer, but for me, this works.

General Ramblings comments edit

Mini cupcake
makerIf you happen to have one of these mini cupcake makers, you can put a dollop of cookie dough in each of the cupcake spots and 11 minutes later – cookies.

You may have to “pop” the tops on them at around 8 minutes. They usually bubble a bit.

There was some highly scientific culinary experimentation involved in arriving at that 11 minute point. Earlier and they just fall apart; later and the cookies are pretty hard.

Note we didn’t use liners, we just threw the dough right in.

Oh, and they don’t turn out pretty. But tasty!

net, gists, testing comments edit

When I’m testing exception handling code, I have tests for exceptions I know I need to handle and tests for exceptions I’m not expecting.

For example, say I have a component that calls a WCF service. If there’s a communication issue, I want to mask that and return some stub/placeholder data. If there’s some other issue, I want to just let the exception bubble up and be handled by a global error handler. Something like this:

public DataObject GetData(SomeParameter p)
  if(p == null)
    throw new ArgumentNullException("p");
  DataObject data = null;
    data = this.SomeService.GetRealData(p);
    data = new StubData();
  return data;

Not a complex scenario. I’ll probably end up with a test component where I can set an exception to be thrown, or use Typemock Isolator to mock a response in the test, like:

  .WhenCalled(() => component.SomeService.GetRealData(null))
  .WillThrow(new CommunicationException());

Then you could do your test, like:

public void HandlesCommmunicationException()
  var component = CreateTheComponent();
    .WhenCalled(() => component.SomeService.GetRealData(null))
    .WillThrow(new CommunicationException());
  var p = new SomeParameter();
  var data = component.GetData(p);

That works well for testing the known exception type. What about the unknown type? You’ll have a test like this:

public void OtherExceptionsBubbleUp()
  var component = CreateTheComponent();
    .WhenCalled(() => component.SomeService.GetRealData(null))
    .WillThrow(new SOME_EXCEPTION_TYPE_HERE());
  var p = new SomeParameter();
  Assert.Throws<SOME_EXCEPTION_TYPE_HERE>(() =>component.GetData(p));

Pick an exception type that you’d never expect to get during normal execution.

Which is to say, if I wanted to see what happens when my component throws something other than a CommunicationException, I’m not going to pick something I might see for real.


  • ArgumentNullException
  • ArgumentException
  • NotSupportedException
  • InvalidOperationException

…or any other sort of “commonly used” exceptions that you might see arise from argument validation or something else.

Why not?

Let’s use ArgumentNullException as an example. Say you add some more validation to the GetData method so that it inspects values in the SomeParameter p coming in. If there’s a specific null value found, you throw an ArgumentNullException. You add tests for that and life is swell.

Except… you didn’t remember to modify the test for your exceptions bubbling up. And, hey, look, it still passes! But it passes for the wrong reason. It’s never actually getting to the service call where you think you’re testing.

Instead, I WOULD pick…

  • DivideByZeroException
  • InvalidTimeZoneException

…or some other exception that you’d never expect to see in the context of what you’re doing. Obviously you’ll have to adjust based on what you’re doing – if you’re doing division in your method, you may actually get a DivideByZeroException, so you wouldn’t use that.

By choosing the right exception, regardless of the refactoring of the class, your test will still pass… and it will pass for the reason you think.

personal comments edit

this isn’t scriptable

there is no template file new automated fill-in-the-blanks cookie cutter copy/paste pattern all input fields validated rule of thumb answer

you need to think

solve problems be creative break out of the mold do the right thing

build a great product

don’t be a script because this isn’t scriptable

be a developer


General Ramblings comments edit

We had a team celebration today at Kells and it was a rather fun murder mystery dinner (well, lunch) theater from Eddie May Mysteries.

The idea is that, while you eat, there are actors who come in portraying different suspects in a murder mystery. You talk to them, they leave “clues” and “evidence” at your table, and at the end you have to figure out who the killer was.

Our mystery took place supposedly in 1929, so all the actors had costumes on and acted like it was the roaring ’20s.

At one point, one of the characters left some “evidence” at our table - a purse with a bloody handkerchief in it.

Now, I’m a fan of mystery movies and such, so the first thing I start thinking is, red herring. I mean, no way it’s going to be this blatant, right?

Finally we got a chance to ask the characters questions, sort of near the end. The actress who had the bloody handkerchief sat down and I started thinking… given the time period… woman with a bloody handkerchief… maybe not living the healthiest lifestyle…

“Are you sick?” I asked.

“What?” The actress looked a little shocked.

“Sick. Are you sick? Like, not mentally ill, but physically. Do you have any disease?”

“Why do you ask?” She looked legitimately confused and started acting like I was being offensive to her character.

“Well, given the time frame, somewhat close to turn of the century, I’m wondering if you have tuberculosis. Consumption. You have a bloody handkerchief in your purse and there’s no way it’s that obvious.”

At this point she actually broke character. “This is what you get when you do the show for smart people. I’ve been doing this show for years and I’ve literally never heard anyone ask that question. Have you ever heard of Occam’s razor?”

I couldn’t help but giggle a little. “Yeah.”

“OK, good. Think way… way… way simpler than that. Truly, you’re overthinking it.” She laughed a little.

So… Maybe I should stop watching so many mystery movies. I always expect it to be this crazy convoluted thing now and I ignore the obvious stuff.

I ended up getting it right, despite over-thinking it.

Anyway, it was a pretty sweet event. The actors were good and were obviously having fun with it, which made it all the more fun for us. I would totally do it again.