Speaking about Mocks in Pleasanton this Wednesday

I am very honored that the East Bay chapter of the Bay Area .Net user group will have me as a speaker this upcoming Wednesday. I’ll be talking “For Those About to Mock”, about Mocks and Stubs in .Net, after a presentation of the unit testing features of Visual Studio by Deborah Kurata – an apt opening topic, if you ask me.

You can find more information about this event here; Hope to see you on Wednesday!

More...

Automatically exclude bin and obj folder in Tortoise SVN

It seems like all the cool kids are using either Git or Mercurial these days, so I feel like a dinosaur sticking to Subversion and Tortoise for version control. In the meanwhile, I just figured out a small Tortoise trick yesterday.

In my experience, the number one dumb mistake that happens with Subversion is adding a new file in a project, and forgetting to add that new file when committing. To avoid this, before a commit, I right-click on my project, and select add, which shows all the local files that haven’t been added to the repository. The problem is that you get a bazillion files this way, some of them you know you are never going to add, like the Bin and Obj folders for instance.

AddFiles

Easy fix: right-click TortoiseSVN, settings, and you’ll see the following:

TortoiseSettings

The text box “Global ignore pattern” defines what patterns you want to exclude; in my case I wanted to remove bin and obj folders, and ReSharper related files, which typically contain _ReSharper, so I added bin obj _ReSharper to the list of patterns. Et voila! Once again, I just wish I had taken the time to read the user manual. This type of dumb process detail just takes a few seconds here and there, but adds up over time; I wouldn’t want to know how many hours I spent un-selecting files in this list over the last 5 years…

More...

VSTO tip: hunt down exceptions when debugging projects

Silence is gold. Or… is it? You may have noticed that VSTO swallows exceptions; that is, if something goes wrong in your add-in code, Office will discreetly carry on as if nothing had happened. Consider the following code:

public partial class ThisAddIn
{
    private int counter;

    private void ThisAddIn_Startup(object sender, System.EventArgs e)
    {
        this.Application.SheetActivate += SheetActivated;
    }

    private void SheetActivated(object sheet)
    {
        MessageBox.Show("Counter = " + this.counter.ToString());
        throw new ArgumentException("Something went south here.");
        counter++;
    }

The add-in is supposed to maintain a counter of how many times the user has changed the activate sheet. However, a bug throws an exception right before the counter is updated. If you run this code, you’ll see that the MessageBox keeps being displayed every time you change the selected worksheet, but the counter stays firmly at zero, and never gets updated.

More...

Challenge: can you find the best plan to refuel locomotives?

Via the INFORMS newsletter, I found out this cool competition (trains and analytics, how much cooler can it get?): can you find the best plan to refuel the locomotives of a railroad company?

Create a cost-effective plan to fuel the locomotives that power a railroad’s trains. Specify how many fuel trucks to contract at each yard and how much fuel to dispense into the locomotives of trains that run over a specified time horizon. Ensure that no locomotive runs out of fuel en route between yards. Sounds easy? We’ll see about that!

Learn more about the challenge at the competition website, and register by June 15, for glory, bragging rights, a shot at a first prize of $2,500 – and help spare some poor chaps an unpleasant day:

More...

Excel 2007 VSTO Add-In tutorial: code sample

Excel VSTO Add-In Series

I finally got to reviewing and scrubbing the code for the part 2 of my Excel 2007 VSTO tutorial; you can download the code here. Next chapter, we will venture into the joys of deployment.

In the meanwhile, please feel free to let me know in the comments what you think, like and dislike, and how I can make this better!

More...