Skip to main content
Trev's Blog @ Infusion Development

Trev

Go Search
Infusion Blogs - Beta
ActiveNick
Alex
Boston
Bryan
Daniel
Greg
kennedy
Kurt
London
Matthew Glace
Nadeem's SharePoint Blog
Recruiting
Rob
Simon
Simon Matthews
Sleepless Blog
Syd Millett
Szymon
Trev
Tyler
  

 Trev: Not Evil (mostly)

See No Evil, Hear No Evil, Speak No Evil

 ‭(Hidden)‬ Admin Links

Infusion Blogs - Beta > Trev
Advancing the fight against quantum bugs.
Drastically improve bug reports with context grabbers

How many times have you (a developer) been frustrated by bug reports along the lines of "XYZ doesn't work!"? The lack of useful information is not only irritating, but it can really drag out the amount of time and effort it takes to fix the problem.

A critical element of tracking down the root cause of a software problem is context. What exact version of the software was being run? Which database were they connected to? Which user ID were they logged in as? - answers to these can really help cut down the time needed to fix a bug.

Getting this contextual information is not always easy. You can't expect a tester or user to fill out a massively long, application specific, form when submitting a bug report (well, you can expect it, but whether the entered information will be accurate and useful is another matter).

There is a fairly simple way to solve this: Build a "context grabber" into your application. A context grabber is a simple utility (usually accessed from a help menu item or hot key) that grabs a snapshot of useful information about the running application and puts it onto the clipboard, ready to be pasted into your issue tracking system. The content can be plain text or rich data (screen shots, serialized and encrypted data from the user's session, debug logs etc), but the point is that is is as simple as possible for the tester/user to use and provides the developers with the information that they need to easily recreate the problem.

In my humble opinion, building a feature like this into your application is at least as important (if not more so) than fully instrumenting the application with debug logs. I think you'll find it to be a lifesaver more than once.

What I picked up in 2007 and looking ahead to 2008

2007 was a big year for me. Having just recently joined Infusion in December 2006, I was packaged up and sent off to New York City for a few months before returning to Toronto to enjoy the rest of the year working via remote desktop.

This post is a laundry list of some of the technologies and techniques that I picked up along the way. Maybe I'll look back in a few years and have a laugh at it... then again, maybe I won't. Isn't this kind of thing what slow Friday afternoons are for? :-)

Distributed Computing

It's an art form, masking itself as a science.

This year, I dug down deep into the bowels of Distributed Computing. I leaned the hard, messy way - retrofitting existing applications that were never intended to be used like this. Learning like this has given me a handy insight and feel for the expectations we should have when implementing these kinds of systems.

Microsoft Excel & VBA

We've taught the proverbial "old dog" a host of new tricks and done things no developer should have to admit to!

Having a decent background in VB6 gave me a good head start into the world of VBA, but what it didn't prepare me for was how versatile an application Excel really is. This year, we've really taken Excel to the limit - who'd have thought that we could use a monolithic client application like Excel.exe to be heart of a sophisticated distributed computing trade pricing application? It's definitely not the best technology for the job, but it fit the bill as being relatively flexible and allowed us to have a very quick development turnaround.

I was recently lucky enough to be a part of one of Infusion's famous Boot Camp training sessions and took it upon myself to learn Excel Services - despite its limitations, I'm very excited about this.

LINQ (and all its flavours)

If you take a look back over some of my previous blog posts, you may notice that I like LINQ a lot. I think it's a major advancement of how we think of data in our applications. DLINQ and XLINQ are similarly exciting... I'd love to get rid of all my boiler plate DL logic with DLINQ and I look forward to the day when I sit down and do some heavy work with XML without having to go near the nasty words XLST or XPath!

SharePoint / MOSS

I can't say I really know this, but the exposure to it I got during the recent Infusion Boot Camp was very useful and opened up a whole new world to me. I see the potential for taking this knowledge a lot further though... it's a massive system with great potential. I really do need to brush up on my web development skills though!

Things to come in 2008...

2008 is shaping up to be an even bigger year, but here are some things that are vaguely on the horizon.

Windows Presentation Foundation

I'm due to take part in another boot camp training session - this time on WPF. I love smooth graphics, but I'm the exact opposite of being a talented designer. I'm excited to see how WPF measures up to the well established world of "traditional" Windows Forms and how well it meshes with Web Technologies.

Distributed & Parallel computing

Despite being around for decades, it's really only starting to become mainstream. The industry will continue to grow (fuelled by multi-core and many-core processor designs). The software will need to evolve to take advantage of the distributed computing power that is out there. Harder still... programmers will need to evolve to better imagine parallel architectures. Scalability will be a key requirement for future software projects.

With the advent of ParallelFX, the future is already looking brighter for developers trying to get to grips with adding parallelism their applications. I'm really looking forward to putting together a series of lunch and learns about the different forms of parallel computing.

Excel, Excel Services and Spread sheets in general

Late at night, in the bowels of the Infusion Toronto office, you may have heard me scream "I hate EXCEL!". I've come to realize that it's not Excel I hate... it's what we're trying to do with it that causes all the screams. We've built up a wealth of knowledge by learning the hard way - I look forward to sharing this through best practices and feedback on how Excel can be improved for future generations.

If you leave automation (VBA or VSTO) out of the picture - you're left with a spread sheet right? I use to think this, but I've come to think of the spread sheet as a development environment of its own. My academic brain wheels are turning....

LINQ

LINQ brings great power to the mainstream. Unfortunately, power like this should only be wielded by the responsible and wise developer. LINQ is new and sufficiently different from what has come before it that we'll have to delve deep into it to come out with a set of best practices. Some see DLINQ as the end to stored procedures, while others see DLINQ as a threat to their beloved stored procedures. I have a feeling that things like DLINQ will fuel many a flame war lively discussion for many a day to come.

Happy New Year folks... let's make it a good one.

My new portable computer - you can build one too!

It's not actually new, and well, it's not actually a computer. But it does make my life a lot simpler. It also saves wear and tear on my laptop and also makes it faster. Perked your interest yet?

I'm actually talking about an external hard drive. Here's some simple steps to follow.

  1. Buy a fast external 2.5" hard drive with a SATA interface.
  2. Buy a sleek and cool looking external hard drive enclosure for it. Make sure it has an eSATA interface if you want to get the best performance.
  3. Buy a PCMCIA eSATA card (if your laptop doesn't have an eSATA port).
  4. Build a Virtual PC image with all the programs that you usually run installed on it and copy it to your external drive.
  5. Leave the laptop at work in the evenings, and take the external drive home instead.
  6. Plug the drive into your home PC (I know you have one, you nerd!) and now you have a fully functioning VPC image with all your programs ready installed! Late night programming, here you come!

Here are some of the advantages I've found of doing this:

  • Because I bought a 7200 RPM drive and am using the eSATA interface instead of USB 2.0, the external drive is actually faster than my internal laptop drive. The VPC loads, runs and shuts down way faster off the external drive.
  • I don't have to carry my laptop home in the rain/sleet/snow.
  • I have way more space on my laptop drive as all the VPC images that I use for demos etc. can now be thrown on to the external drive.

Some recommendations:

  • Do your research... make sure you get what you pay for. It's still easy to get confused between ATA, SATA, eSATA, USB, FireWire. Something as simple as a shipping mistake can ruin your day.
  • 2.5" is nice for carrying around and doesn't usually require an external power supply. 3.5" will be slightly faster (due to the higher linear velocity at the same RPM), but are these really that portable?
  • Don't store sensitive data on the portable drive. Privacy concerns are one reason. Also dropping the portable HDD down the slippery staircase at the entrance to a subway is not a good excuse to tell your boss when you lose or corrupt the source code for the super-hot app you're working on.
  • Personal experience: I have the Vantec NexStar 3 eSATA enclosure surrounding a HITACHI 80GB 7200 RPM drive with a Vantec PCMCIA eSATA card and I love it.
  • The only disadvantage is that eSATA isn't a powered interface, so you need the eSATA cable for data transfer and an USB cable for power.
  • Wait a little while and get yourself a super fast, solid state, flashed based HDD instead of a mechanical one.
Data Driven Unit Tests with Visual Studio 2005 Team System

A while ago, I attended a user group meeting on the subject of unit testing using VSTS in the real world. It was an interesting talk and opened me up to some of the novel techniques that can be used in the realm of unit testing. One of these techniques was data driven unit tests and in this post, I'll walk you through creating such a test.

Introduction to data driven unit tests

A data driven unit test is very similar to a normal unit test, except that it is run a number of times, each time with a different set of inputs. The inputs to the unit test usually take the form of some kind of data source (such as a CSV file or database). For each row in the data source, the test host system will invoke the unit test.

Data driven tests are useful when you need to test with a range of input values (e.g. boundary conditions or a specific set of values that are known to cause trouble). Instead of writing a number of unit tests where each one tests a single value, you write the test once and provide a list of different inputs to test.

At a high level, in Visual Studio 2005 Team System, you can create unit tests by taking the following steps:

  1. Create the data source for the data driven unit test. This takes the form of a table of values where the columns represent inputs to the unit test and the rows represent separate unit test runs.
  2. Add the [DataSource()] attribute to the unit test, specifying the location of the data.
  3. Write your unit test. Instead of hardcoding input values (such as the proverbial expected value), read them from the current test data row instance using TestContext.DataRow["ColumnName"] where "ColumnName" is the name of the column you wish to get the current value for.
  4. Run your test. You should notice that the total test count reflects the number of rows in the data source, not the number of tests you have written.

How to write a simple data driven unit test

This tutorial will show you how to write a simple data driven unit test to test a simple mathematical addition function.

Step 1: Create the Visual Studio solution

image

We need to have something to test. For these purposes, let's start with a simple class library called "Math".

Once you have created the blank class library, create a class called "Adder" and add the following method body.

/// <summary>
/// Adds two integer values together
/// </summary>
/// <param name="x">The first value</param>
/// <param name="y">The value to add to the first value</param>
/// <returns>The result of x+y</returns>
public int Add(int x, int y)
{
    return 0;
}

Notice that we have left the method body empty (except for the return statement to allow it to compile). This will hopefully cause our tests to fail to allow us to demonstrate that our test is indeed working.

Step 2: Create the unit test project

imageRight click on the "Add" method signature and select "Create Unit Tests..." you should be presented with the dialog shown that will allow you to automatically create a unit test stub.

When you click "OK", you should be presented with a unit test stub similar to the following.

/// <summary>
///A test for Add (int, int)
///</summary>
[TestMethod()]
public void AddTest()
{
    Adder target = new Adder();
    int x = 0; // TODO: Initialize to an appropriate value
    int y = 0; // TODO: Initialize to an appropriate value

    int expected = 0;
    int actual;

    actual = target.Add(x, y);

    Assert.AreEqual(expected, actual, "Math.Adder.Add did not return the expected value.");
    Assert.Inconclusive("Verify the correctness of this test method.");
}

Leave the code as is for now... we'll modify it later.

Step 3: Create your data source

For the purposes of this test, we'll define a data source to hold a set of values to test with. The container for the data will be a comma separated values text file (.csv) and it will contain 4 columns  and a number of rows as shown (the first row contains the column names).

X,Y,Expected,Comment
1,1,2
2,3,5
-1,2,1
1,-1,0

To add this data to the unit test project, select the project in the solution explorer, right click and select "Add -> New Item...". Select "Text File" from the list of items, enter a filename (e.g. "AddTestData.csv") and click "OK". Enter the data into the CSV file and save it.

You'll notice that we've left the last column as a free text comment column. Although not used directly in this demo, it can come in useful when trying to identify rows that cause the test to fail as we can append the comment to any messages that we print out to the unit test host system.

Step 4. Configure the data source

In order to use the CSV file as a data source you need to give Visual Studio some information about it (e.g. where to find it and the data source provider to use).

First of all, we need to ensure that the file gets deployed with our tests. To do this, double-click on the "localtestrun.testrunconfig" file that was automatically created by Visual Studio. You should be presented with a dialog like the one illustrated below.

image

Select the "Deployment" configuration section and click "Add File...". This will allow you to select files that will get distributed along with the unit tests.

In our case, we want to distribute the file that contains the data for our data-driven test ("AddTestData.csv"), so add it to the list.

Each time our tests are run, this file will get copied into the same folder as the binaries for the unit test.

 

In order to tell Visual Studio how to read the data contained in our file, we need to add a configuration file and specify the data provider implementation. It's possible to do this with attributes on our unit test itself, but doing it in an application config file is cleaner and allows you to easily share data sources between different unit tests.

Once you have added a blank application config file to your unit test project (Add -> New Item -> Application Configuration File) you can add the following XML (see the comments for an explanation of the different sections.

 

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="microsoft.visualstudio.testtools"
    type="Microsoft.VisualStudio.TestTools.UnitTesting.TestConfigurationSection, 
Microsoft.VisualStudio.QualityTools.UnitTestFramework,
Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
"/> </configSections> <!-- Defines connection strings for the data--> <connectionStrings> <!-- The connection string to get CSV data from the current test folder. Each CSV file will represent a different table in the data source--> <add name="CSVData" connectionString="Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=;Extensions=csv" providerName="System.Data.Odbc" /> </connectionStrings> <!-- Data sources for data driven tests. Note that "#" instead of "." is used for the file extension--> <microsoft.visualstudio.testtools> <dataSources> <!-- The data table we'll use for running the Add() metod tests--> <add name="AddTestDataSource" connectionString="CSVData" dataTableName="AddTestData#csv" dataAccessMethod="Sequential"/> </dataSources> </microsoft.visualstudio.testtools> </configuration>

Step 5. Implement the data driven unit test

Once you have saved the application file, go back and edit the code for your unit test. It should look like the following. Notice how we have specified a [DataSource()] attribute and we get the input and expected values now come from the DataRow property on the  TestContext object.

/// <summary>
///A test for Add (int, int)
///</summary>
[TestMethod(), DataSource("AddTestDataSource")]
public void AddTest()
{
    Adder target = new Adder();

    int x = (int)TestContext.DataRow["X"];
    int y = (int)TestContext.DataRow["Y"];

    int expected = (int)TestContext.DataRow["Expected"];
    int actual;

    actual = target.Add(x, y);

    Assert.AreEqual(expected, actual, "Math.Adder.Add did not return the expected value.");
            
}

Step 6: Run the unit tests and watch them fail

If you build the solution and run the unit tests, they should fail as we have not provided a valid implementation for the Add() method. You should notice that the test count reflects the number of rows in your data source - showing that your test was invoked once for each row. (The one successful result shown below was because one row in my input data contained an expected result of 0 - exactly what we return in our method stub)

image

If you double-click on the test, you will be presented with a listing of each test invocation, detailing which rows passed and failed:

image

Step 7. Implement the method and re-run the tests.

I'll leave this step up to you... I'm sure you can figure it out. :-)

Unit Tests can do more than test your code

The overwhelming majority of Unit Tests are probably used to test code for defects or failure conditions and it may not surprise you that many unit test frameworks (such as JUnit, NUnit or Visual Studio Team System) were designed with this sole purpose in mind.

A thought came to me the other day that unit tests could also be used to test the integrity of various systems. In my case, we have a large end of day processing system that consists of many disparate processes and we don't really have a central place where we can check the integrity of the data. We usually resort to running a stored proc here, checking a status email there, and monitoring for individual processes that may have failed or completed earlier than they should have.

Instead of spending a large amount of time writing a dashboard-like application that would need to be flexible enough to change when some of our processes change, I came up with the idea of leveraging the unit test system to run a series of pass/fail tests on the data consumed and generated by our end of day process. Each test would be a small indicator of the health of our system and we could run all tests in a host application like Visual Studio Team System and immediately get a mile high view of problem areas.

The best things about this approach are:

  • It requires little or no initial investment (really.. how long does it take to write a unit test that checks for the existence of data in a database table?!)
  • A library of tests can be built up over time. If a failure condition is found, write a unit test for it. If a process change renders a test obsolete, disable the test.
  • The host application needed to run the tests and report on success or failure already exists (i.e. your existing unit test framework).

Examples of some tests that you can create:

  • Ensure that input data exists before running
  • Ensure that the correct number of results exist
  • Ensure no errors were logged in the event log
  • Set up "soft" tests that serve as warnings... e.g. there's a large difference between values calculated today as opposed to those calculated yesterday.

However, this technique is not a magic bullet. Because the unit test host applications were designed for testing software they can often lack some of the features necessary for turning them into flexible dashboard applications. Even a simple thing like adding parameters to your unit tests can be tricky (e.g. to specify criteria to search for when checking the existence of data).

Despite some of the limitations, this technique can provide a valuable short term solution in place of a larger dashboard-like application. All need not go to waste if that dashboard application comes along in the future... by their very nature, the unit tests themselves should be self contained and portable enough to be easily incorporated into the dashboard in the future.

VBA Exploder is no more

In an earlier post, I proposed a CodePlex project to automate the exporting and importing of VBA code files for Excel. As is the norm for me, other priorities, responsibilities (and a touch of me not being very interested) have gotten in the way of me doing any work on it.

Today, I came across a handy utility that is capable of doing the same thing. It's called Code Cleaner and is a COM add-in for Excel. Its main purpose is to clean the "junk" from your VBA projects by exporting all modules and then re-importing them and seems to solve some random issues that can crop up from time to time (it solved a "Bad DLL Calling Convention" error that I was getting today). Aside from its cleaning abilities, you can also use it to export and import all the VBA modules for you.

In light of this, I'm shelving the VBA Exploder project on CodePlex. Although the Code Cleaner utility doesn't go as far as I had originally hoped VBA Exploder would (i.e. A full command line compiler / decompiler for Excel workbooks), its functionality should suffice for most uses.

My humble apologies.

A step towards the unified theory of the universe, or simply an adaptable algorithm?

To 42 or not to 42?

There are a few algorithms out there in the world of computer science and mathematics that seem to crop up everywhere. Take the Monte Carlo class of algorithms as an example – they are used in the financial industry as well as to attempt to beat humans at the game GO. Hell, even Joel Spoolsky’s FogBugz project management software contains an implementation of the algorithm to give project managers an estimate on the likelihood that a release will happen on a specific date in the future.

The question rolling around in my empty head is this: Is the Monte Carlo algorithm spectacularly adaptable, or is it a representation of a misty window into the fact that underlying mechanics that drive these varied systems are one and the same? Are we stepping closer to the answer to life, the universe, and everything? With the mathematical and statistical tools at our fingertips, are we brute-forcing our way towards Albert Einstein’s Unified Theory?

Um, maybe not. The Monte Carlo algorithm has a random (or pseudo-random) component built into it. Does this mean that all the systems that it models contain a random component too? Maybe. Then again, the “randomness” we observe in these everyday systems might be down to the fact that they have a large degree of freedom (resulting in an unimaginably huge number of outcomes) which we are only capable of comprehending as being random.

Despite the fact that I know nothing about what I am rambling on about above, I find it interesting in a weird kind of way. It’s like realizing that your favourite chocolate cookie is made at the same factory as Aston Martins and imagining the possibilities that can arise in the future: Fast cookies; chocolate super cars; super cars that cost as much as a cookie.

Right… enough rambling. Crazy enough for one day methinks.

Managed code and COM Single Threaded Apartments (STA’s)

Recently I’ve been developing an ASP.net web site which ultimately calls a 3rd party COM component to do some work for it. All seemed well and good - my unit tests for this particular piece of code worked. My level of being chuffed with myself was brought down a peg or two when I tried calling my code from an ASP.Net web site (or remoting client, or console application). I was stumped for a long time until I tried calling the code from a Windows Forms app – lo and behold it worked. Humm. What could be the difference between a Windows Forms environment and any of the three mentioned above?

The answer lies in a little attribute called the [STAThread] attribute that is normally placed on the Main() method of Windows forms applications. The COM component I was calling required a Single Threaded Apartment and was failing when called from the free threading model that is the default for ASP.Net, remoting (which uses the ThreadPool), and console applications. The reason why it seemed to work in unit tests is because the thread that Visual Studio 2005 used to run the tests must have been an STA thread.

To make the code work from a console application is a simple matter of placing the [STAThread] attribute on the main method. Getting it to work from ASP.Net or through remoting is a little bit trickier as there’s no easy way to tell these environments to use an STA thread (it’s not impossible, but it is not always desirable for performance reasons). To cleanly solve this issue, I set about to create a utility that is capable of making sure my calls get executed on an STA thread without having the whole application live in a single threaded apartment.

The code for this utility is attached. It’s a simple static class that leverages the facilities exposed by the System.EnterpriseServices namespace to create a COM+ STA thread pool. To use it, you wrap your calls up in a STACall delegate and volia… your method gets run (synchronously) on an STA thread. I won’t go into too much detail here… the unit test project supplied should allow you to figure out the mechanics for yourself. The important thing to remember is that you must do all your work on the STA thread – creating, calling and destroying the COM object in question.

During my research on this topic, I came across a number of very useful and well written articles on the subject of COM STA’s… well worth a read if you’re still living in the COM world and want to dig a little deeper than the “Add Reference” dialog.

Understanding The COM Single-Threaded Apartment Part 1: http://www.codeproject.com/com/CCOMThread.asp

Understanding The COM Single-Threaded Apartment Part 2: http://www.codeproject.com/com/CCOMThread2.asp

Understanding Classic COM Interoperability With .NET Applications: http://www.codeproject.com/dotnet/cominterop.asp

The first article perfectly captures the difficulty most people have in understanding what a thread apartment is:

1.       They are created by implication. There are no direct function calls to create them or to detect their presence.

2.       Threads and objects enter apartments and engage in apartment-related activities also by implication. There are also no direct function calls to do so.

3.       Apartment Models are more like protocols, or a set of rules to follow.

Below are a few features that I’d like to see implemented in Visual Studio to make dealing with COM interop easier:

·         Some kind of compiler warning that is displayed whenever a COM object is referenced from an application that has a different threading model

·         A way of marking certain managed code so that other developers can be properly warned that this code calls an STA COM object

·         A formal way to specify the kind of threading apartment that should be used for running unit tests that invoke COM objects

·         A neat little utility to make STA COM objects usable from ASP.Net or remoting applications (like the one I have attached) built in to the .Net framework

Here is the sample code (VS2005, C#) for the STAInvoker class.

Incidentally, this could also be handy if you’re trying to automate Office applications (e.g. Word, Excel etc.) on the server – they seem to behave much better under an STA environment.

One final recommendation… build better unit tests so that you test your objects under the threading model(s) that they will likely be run under. My experience is a prime example how a unit tested code can fail in really strange and unexplained ways. The unit tests I provide in the example are basic and don’t really cover that many use cases, so please expand on them.

Upcoming advances in the realm of parallel computing
Performance and scalability are a keen interest of mine, so I'm always glad when new developments happen in this arena. I love contemplating this stuff even though my current work has me thinking in the decidedly non-parallel world of Excel!
 
Here’s a small aggregation of resources that will hopefully perk your interest.

 
Parallel LINQ (PLINQ)
This is an addition to the LINQ framework (courtesy of ParallelFX) that allows LINQ-To-Objects and LINQ-To-XML queries to be executed in parallel with very little changes to existing code. Its powerful stuff wrapped up in a simple to use API. Just think about it… querying usually involves loops. Many loops can be executed in parallel. PLINQ exists. End of story.

It’s worth noting that LINQ-To-SQL won’t take advantage of PLINQ… the parallelism is already achieved by the underlying data provider (e.g. SQL Server).
 
A full article on the subject can be found in this month’s MSDN Magazine: http://msdn.microsoft.com/msdnmag/issues/07/10/PLINQ/default.aspx
 
Task Parallel Library (TPL)
This is a library that is designed to make it relatively easy to parallelise code. Don’t get too exited… it doesn’t magically get rid of issues like shared memory management for you. Instead it provides simple constructs that allow you to parallelise code that is normally sequential in nature without the need to go digging into thread pools or background workers.

C# 3.0 Example
Consider a simple for loop that adds two arrays (a and b) together into a third array (c). The sequential way to do this would be:

for (int i=0; i < 5000; i++)
{
 c[i] = a[i] + b[i];
}

This is a good candidate for parallelism as no shared memory is involved (each loop iteration only deals with array elements for the current index.) If we were to parallelise it using existing methods, we’d end up creating a bunch of work units and executing these in parallel using multiple threads…  not a trivial (or clean) task to do. However, using the TPL API, it’s easy to turn our for loop into a parallel for loop:

Parallel.For(0, 5000, delegate(int i)
{
 c[i] = a[i] + b[i];
});

As you can see, we can easily wrap the body of our for loop in a delegate and pass it to the Parallel.For method for parallel execution for 5000 iterations. The TPL takes care of thread and load balancing suitable for the machine it is being executed on.

Within the TPL, most units of work get done with a kind of thread pool implementation. I’m really glad to see that the designers of the TPL have gone to great lengths to optimise the thread pool to use dynamic work distribution algorithms. This leads to higher utilisation and less context switching than static work distribution techniques and can mitigate the impact that blocked threads can have on the overall throughput of the system. In the near future, I’ll post a quick rundown of some of the techniques that have been employed.

Again, this month’s MSDN Magazine features an in-depth article on this: http://msdn.microsoft.com/msdnmag/issues/07/10/Futures/default.aspx
 
Metro Toronto .Net User Group - Unit Testing with VSTS in the Real World

Tonight I attended a presentation by Dave Lloyd at the Metro Toronto .Net User Group. Overall, it was a pretty solid presentation with just the right level of technical detail (i.e. there was no “this is a unit test and this is how you run it” kind of stuff). Dave was a pretty decent presenter and although there wasn’t much in the way of deep-dive demos, he did a good job of staying away from the dreaded PowerPoint. Dave assumed the audience had a basic level of understanding of unit test development, allowing the presentation to concentrate on some of the trickier problems one might face during development.

Some of the topics included:

  • .VSMDI Problems
    Apparently .VSMDI files are the source of many problems. A simple
    Google Search will give you a sample of complaints. Dave’s recommendation is to have a gold copy of the main solution and .VSMDI files in source control that can’t be edited by the team (only the admin). Each developer then has their own solution files and local .VSMDI files. This mitigates the problem of corrupt .VSMDI files resulting from merges or multiple developers editing them. Allowing each developer to have their own local solution file allows that developer to load a subset of the projects in the full solution – enhancing the performance of Visual Studio.
  • .testrunconfig files
    What they are and how you can use them
  • Migrating from nUnit to VSTS
    Beware of the different order that the Class Initialize and Class Cleanup methods are called between the two systems.
  • Raising awareness of other features
    According to Dave, features like, Build Servers, ExpectedException, Data Driven Tests etc. aren’t used enough.

The refreshing thing about this presentation is in its title – “Real World”. I’ve gone to a few too many presentations about cool new (unproven) technologies which do a great job for evangelism, but don’t do much to help us solve problems with the technologies we are using in the present day. Dave talked in great length about some of the pitfalls with VSTS and some of the workarounds that you can use to alleviate some of the headaches that can occur. I will definitely be keeping this idea in mind from now on for presentations and articles I have planned. (Of course that will go out the window when I post about LINQ ;-)

I’ll update this post with links to the presentation materials as soon as they become available. In the mean time:

Metro Toronto User Group

Dave Lloyd’s Blog

1 - 10 Next

 What I'm working on

VB6 & VBA Standards and Best practicesUse SHIFT+ENTER to open the menu (new window).
24/09/2007 22:11
Excel Server-Side Technology ReviewUse SHIFT+ENTER to open the menu (new window).
24/09/2007 22:10

 Recent Posts

Drastically improve bug reports with context grabbersUse SHIFT+ENTER to open the menu (new window).
11/02/2008 13:430
What I picked up in 2007 and looking ahead to 2008Use SHIFT+ENTER to open the menu (new window).
28/12/2007 15:040
My new portable computer - you can build one too!Use SHIFT+ENTER to open the menu (new window).
26/11/2007 22:253
Data Driven Unit Tests with Visual Studio 2005 Team SystemUse SHIFT+ENTER to open the menu (new window).
12/11/2007 17:442
Unit Tests can do more than test your codeUse SHIFT+ENTER to open the menu (new window).
12/11/2007 11:340
VBA Exploder is no moreUse SHIFT+ENTER to open the menu (new window).
31/10/2007 17:410
A step towards the unified theory of the universe, or simply an adaptable algorithm?Use SHIFT+ENTER to open the menu (new window).
24/10/2007 18:220
Managed code and COM Single Threaded Apartments (STA’s)Use SHIFT+ENTER to open the menu (new window).
18/10/2007 21:320
Upcoming advances in the realm of parallel computingUse SHIFT+ENTER to open the menu (new window).
11/10/2007 00:392
Metro Toronto .Net User Group - Unit Testing with VSTS in the Real WorldUse SHIFT+ENTER to open the menu (new window).
24/09/2007 22:040