September 2006 Entries

Custom Build Numbers in Team Build

The Team Build service in Team Foundation Server includes the current date in the build number by default. To me, the string looks like the random gibberish of a disk head crash. FooBarBuild_20060928.1FooBarBuild_20060928.2… I know some people are fond of including the date in a build label, but it's a turn off for me. Build labels have a tendency to show up in many places, and a friendly number is easier on the eyes. FooBar_2.5.1FooBar_2.5.2…FooBar_2.5.176 Fortunately, it's easier to change Team Build with a custom MSBuild task. There are some examples of how to do this out there, but none that generate a truly friendly...

Removing Features Considered Harmful

I get the occasional earful from people who are upset with Microsoft. These rants might come electronically, or they might come in person. If I know anything about the particular problem the person is having, I might try to give them some perspective or background on why Microsoft made the software do whatever it is that is causing the person great pain and suffering. I might know a workaround, or I might not. I might make them happier, or I might not. I do try. C'est la vie. Today, I am on the other side of the fence. I updated...

What's Wrong With This Code (#6)

Joe Developer is working on a new application for a book publisher. Authors can publish zero or more books. Books can have zero or more authors. Joe wrote a query to get a total count of all authors, and a total count of all books. Joe read on the Internet that the DISTINCT keyword is good to use in these scenarios. SELECT DISTINCT  COUNT(Authors.Id) AS TotalAuthors,  COUNT(Books.Id) As TotalBooksFROM  Authors    FULL JOIN AuthorsBooks AB ON Authors.Id = AB.AuthorID  FULL JOIN Books ON AB.BookID = Books.Id The problem is - the numbers seem too high. What's wrong? Is it easy to fix?

State Machines In Windows Workflow

A new article on OdeToCode: State Machines In Windows Workflow. State machines have been a powerful abstraction in software for many years. Using a state machine in Windows Workflow means we get all the tracking, persistence, and meta-data support the workflow runtume offers, which is quite a bonus.

When to set AspCompat

If we interop with a COM component from ASP.NET, we might need to use AspCompat="true" in the @ Page directive. The question is: when do we need AspCompat? The answer is that we need AspCompat if the COM component has to run on a thread initialized into a single threaded apartment (STA). This begs the question: how do we know if a component needs to run in an STA? One answer is to dig into the HKEY_CLASSES_ROOT section of the registry and find the component by CLSID (or by ProgID, which can give us the CLSID). Inside will be an...

Forum Quote Of The Day

From an ASP.NET discussion:    "Real men don't write code, they regenerate it." Use the comments to discuss the technological, grammatical, and sociological aspects of this statement.

The Art of Escalation in Software Requirement Meetings

Maybe you've dealt with The Escalator before. The conversations with The Escalator go something like this: "Now, what about this scenario? This is a very high-priority scenario for our users. We have to have this feature in the next release". "We costed that scenario, and we don't have the time in this release". "But this is a high priority scenario." "Every feature in this iteration is high priority". "You don't understand, our user's can't do their jobs without this feature. If we don't deliver this, the project will fail". "But, it was never that important before…" "Look – if we don't...

Let's Get Threaded

Threading. It's the new frontier. At least, that's what all the cool articles say these days. The premise is that we have these new fangled dual core chips, but our applications aren't taking advantage of all the horsepower available because we don't use enough threads. We need to use more threads, they say. We have to grab those chips by their cores and bend every transistor to the will of our application. Imagine if your local government doubled the width of all the roads in your area, and car manufacturers followed up by doubling the size of all new cars....

What's Wrong With This Code (#5)

Joe Developer is working on a bowling program (again). Joe wrote the following code. using System;using System.Collections.Generic;[Serializable]class Bowlers{    List<string> _bowlerList = new List<string>();    public void AddBowler(string name)    {        _bowlerList.Add(name);        EventHandler<BowlerAddedEventArgs> handler = BowlerAdded;        if (handler != null)        {            handler(this, new BowlerAddedEventArgs(name));        }    }    public event EventHandler<BowlerAddedEventArgs> BowlerAdded;    // ...}[Serializable]class BowlerAddedEventArgs : EventArgs{    public BowlerAddedEventArgs(string name)    {        Name = name;    }    public string Name;} Joe unit tested the code to within an inch of its life, so he was surprised when another developer wrote the following program, which throws an exception. using System;using System.IO;using System.Runtime.Serialization.Formatters.Binary;class Test{    public static void Main()    {        Bowlers bowlers = new Bowlers();        string addedMessage = "Added bowler: {0}";        bowlers.BowlerAdded +=            delegate(object sender, BowlerAddedEventArgs e)            {                Console.WriteLine(addedMessage, e.Name);            };        bowlers.AddBowler("Bob");        bowlers.AddBowler("Jan");        bowlers.AddBowler("Ann");        using (MemoryStream stream = new MemoryStream())        {            BinaryFormatter...

This Could Be a Team Foundation Server Kind of Week

A few weeks ago, the company I'm working with made an acquisition, thus becoming a slightly bigger, more distributed company. The acquisition started a chain of events that ultimately resulted in me pitching Team Foundation Server (TFS) to a group of executives and developers. The pitch was successful - at least I've been told the licenses can be purchased this week. It was an interesting (and sometimes frustrating) experience getting to this point…. ProblemsThe acquisition forced a reevaluation of existing tools and processes. With the exception of Visual Studio and SQL Server, all the tools used for product development are...

New Article on Windows Workflow Rules and Conditions

If you only look at one feature in Windows Workflow, look at the Policy activity. The Policy activity processes rules. Business rules, game rules - any type of declarative knowledge. Read more in the latest OdeToCode article - "Windows Workflow - Rules and Conditions". The Policy activity is easy to use, and provides a boatload of functionality out of the box. You can prioritize rules, and track rule processing in detail. WF provides an API to modify rules at runtime, which provides a great deal of flexibility. Rules execute with forward chaining semantics, meaning the rules engine analyzes the dependencies and...