Rants, rambles, news and notes from another geek

My VS2012 Wallpapers

I’m getting ready for TechEd 2012 this month and realized I wanted to have a nice desktop wallpaper for my laptop. Well, I’d not seen any popping up on twitter or blogs yet, so I grabbed my trusty GIMP image editor and some base images of the new VS 2012 logo and got to work.

Here are a few of my favorites, but I’ve not decided which I will use on my laptop.

My Speaking Schedule - 2012

I tweeted a bit about the craziness coming up for me in June, but I realized today that I’ve not posted the whole schedule. So if you’re interested and wondering what I’ll be talking about, here’s the complete list (in chonological order).

The first two are now behind me, but the twin TechEds are coming up fast. Also, I’ve got a couple that are currently “maybes” so once they are confirmed I’ll update this post. If you want to contact me about speaking at an event, please use my about.me contact page.

My Take on Unit Testing Private Methods

The simple answer: Just Say No™

Every now and then I get an email, see a forum post, or get a query at a conference about this topic. It typically goes like this:

“When you’re doing TDD, how do you test your private methods?”

The answer of course, is simple: You don’t. And you shouldn’t.

This has been written up in numerous places, by many people smarter than I, but apparently there are still people who don’t understand our point.

Updated NUnit Plugin for VS11 Released

Good news!! Last night I got an email from Charlie Poole, the maintainer of NUnit pointing me to a blog post he’d just made:

Today, I’m releasing version 0.92 of the NUnit Adapter for Visual Studio and
creating a new project under the NUnit umbrella to hold it’s source code, track
bugs, etc.

In case you didn’t know, Visual Studio 11 has a unit test window, which
supports running tests using any test framework for which an adapter has been
installed. The NUnit adapter has been available on Code Gallery since the
initial VS Developer preview. This release fixes some problems with running
tests that target .NET 2.0/3.5 and with debugging through tests in the unit
test window.

Games I'm Enjoying Lately

I first started playing games on computers the day after we got our first computer way back in 1978 or 1979 on our venerable Ohio Scientific Challenger 4P. Man, those were good times. Tanks and mazes… that was about all we had.

In the 80s, when we lived in Egypt and had an Apple II+, I would type the games in, line-by-line, from the backs of magazines. I’m still convinced that I really learned to debug computer programs back in these days.

And I’ve been a gamer ever since.

Lately, I’ve been playing a bunch of different games, looking for something that I can really get into for a while. Although I’ve had fun playing almost all of them, I’ve still not found any with real staying power for me. But I have had a chance to play a number of different games on a few different platforms.

Here are some review of what I’ve been playing lately, and a look to what I’m waiting for.

Kata - the Only Way to Learn TDD

Lately I’ve been asked by more and more people inside Microsoft to help them really learn to do TDD. Sure, they’ve read the books, and probably some blog posts and articles, but they are struggling to figure it out.

But with so many people talking about how good it is they are frustrated that when they try to apply it at work, in their day job, it just doesn’t seem to work out.

My guidance to them is simple. Do a TDD kata every morning for two weeks. Limit yourself to 30 minutes each morning. Then pick another kata and do it again.

Visual Studio Fakes Part 2 - Shims

Let me start by saying Shims are evil. But they are evil by design. They let you do things you otherwise couldn’t do, which is very powerful. They let you do things you might not want to do, and might know you shouldn’t do, but because of the real world of software, you have to do.

The Catch-22 of Refactoring to Enable Unit Testing

In the first part of my series on VS11 Fakes, I reviewed Stubs, which are a simple way of creating concrete implementations of interfaces and abstract classes for use in unit tests.

But sometimes it happens that you have to test a method where the dependencies can’t be simply injected via an interface. It might be that your code depends on an external system like SharePoint, or simply that the code news up or uses a concrete object inside the method, where you can’t easily replace it.

The unit testing agilista have always said, “Refactor your code to make it more testable,” but therein lies the rub. I will again refer to the esteemed Martin Fowler for a quote:

How to Avoid Creating Real Tasks When Unit Testing Async

UPDATE: Stephen Toub pointed out that in .NET 4.5 you don’t need my CreatePseudoTask() helper method. See the bottom of this post for more information.

If you’ve been coding in VS11 Beta with .NET 4.5 you may have started experimenting with using async and await in your programs. You also probably noticed a lot more of the APIs you consume are starting to expose asynchonous methods using Task and Task<T>.

This technology let’s use specify that operations are long running and should be expected to not return quickly. You basically get to fire off async processes without you having to manage the threads yourself. Behind the scenes, the necessary state machine code is created and, as they say, “it just works”.

I would really recommend reading all the great posts by Stephen Toub and others over on the PFX Team blog. And of course the MSDN Docs on the Task Parallel Library should be reviewed too.

But did you know that in VS11 Beta you can now create async unit tests? Both MS-Test and the newest version of xUnit.net now support the idea of a unit test that is async, and can therefore use the await keyword to block on a call that returns a Task.

Editing Octopress/Jekyll Posts in Vim

Update - I was able to get backtick code blocks working much better, and made a stab at the YAML Front Matter, but it doesn’t seem to work using syntax include. See the git repo for the updated source.

I use Vim as my day-to-day, non-IDE text editor. Yeah, I know everyone is in love with Notepad2, Notepad+ or whatever the new favorite on the block is. I’ve been a vi/vim guy for ages and am not gonna change.

Since switching my blog to Octopress, I’ve been writing all my posts in Vim. Vim does a nice job with Markdown, but it doesn’t know anything about the other things that are often used in a Jekyll markdown file.

The two big things are:

  1. It gets confused by the YAML Front Matter
  2. It can go nuts over some of the Liquid filters and tags

Fortunately Vim has a nice way of letting you add new things to an existing syntax definition. You just create another syntax file and put it in the after directory in your ~/.vim directory. Then you just add the new syntax descriptors and restart Vim.

Rules of the Road (Redux)

It is so much fun to go back and look at old posts. I saw Scott Hanselman mention on Twitter that he’d recently marked his 10th anniversary as a blogger. Since I just converted all my posts from SubText to Markdown, I’ve been going through the older ones. Sometimes I find one and say “Ugh, did I really say that?” but other times I find a good one and it still resonates with me as much as it did when I originally wrote it.

This is about one of those good ones.

The post I found was from January 29, 2009 and was called Rules of the Road. In that post I talked about how I found these stashed away in a OneNote file from 2006, so these have been with me for a while.