Monthly Archives: November 2005

1 Comment

Jan Schreuder has blogged on BloggingAbout.NET before about cyclomatic complexity. Go read it if you don't know the importance of keeping the cyclomatic complexity of methods reasonably low. Jan mentioned the tool DevMetrics to check it. I used C# Refactory in the past for calculating metrics.

Code analysis in Visual Studio 2005 Team System now includes a rule to enfore this as well. The rule is CA1502: Avoid Excessive complexity and can be found in the Maintainability Rules category. The VS2005 documentation states this about the rule:

Cyclomatic complexity measures the number of linearly independent paths through the method, which is determined by the number and complexity of conditional branches. A low cyclomatic complexity generally indicates a method that is easy to understand, test, and maintain. The cyclomatic complexity is calculated from a control flow graph of the method and is given as

cyclomatic complexity = the number of edges - the number of nodes + 1

where a node represents a logic branch point and an edge represents a line between nodes.

The rule reports a violation when the cyclomatic complexity is greater than 25. The following cyclomatic complexity thresholds determine the Message Level associated with the violation:

25< Warning
50< Critical Warning
75< Error
100< Critical Error

I think 25 is too high a value before giving a warning. Unfortunately these limits are set in stone in VS2005 and cannot be changed. The values given here seem more reasonable to me:

Cyclomatic Complexity Risk Evaluation
1-10 a simple program, without much risk
11-20 more complex, moderate risk
21-50 complex, high risk program
greater than 50 untestable program (very high risk)

1 Comment

Please read part 1 first. In that post I suggested to add a code analysis check-in policy to Team System with no rules selected if you only want to enfore a clean build policy. This is necessary because the separate clean build check-in policy has disappeared from Team System after Beta 2.

To comply with the code analysis check-in policies set on a Team Project, the code analysis settings on the Visual Studio project within a solution must be set to be at least as strict. I.e., stricter is fine, but more relaxed is not. This is a screenshot of the settings for a project:

Screenshot of the Code Analysis Settings for a project (click for larger version)

You can merge the settings from a Team Project over on to a Visual Studio project through the menu item File | Source Control | Migrate Code Analysis Policy Settings to Solution. This adds the rules in the Team Project Policy that have not already been set on the Visual Studio projects within the current solution. It leaves additional rules set on the projects in place.

As it turns out, it is okay to have not any rule set on the Team Project code analysis check-in policy. But Visual Studio will give you a CA0051 No rules were selected compilation error when you do the same on a project:

Screenshot of CA0051 No rules were selected error in Visual Studio 2005 (click for more details)

Nevertheless if the build was succesful, Visual Studio remembers this and you can check-in your code without any problems.

To get rid of the non-fatal "compilation" error you have to select at least one rule, like in the screenshot above, to stop Visual Studio from complaining.

1 Comment

The clean build policy is indeed gone from Team Foundation Server Beta 3.

If you only want to enfore that a project builds without errors before you can check-in one or more of its files, you must now use the code analysis check-in policy.

You can add a code analysis check-in policy through the menu item Team | Team Project Settings | Source Control. Go to the tab Check-in Policy and click the Add button. Select Code Analysis and click OK. Now the Code Analysis Policy Editor appears. You can deselect all of the code analysis rules and Visual Studio will still check for a succesfull build before allowing a check-in, like so:

 Screenshot of the Code Analysis Policy Editor of Visual Studio 2005 Team System (click for larger version)

Here is a screenshot of the policy violation on check-in that occurs when a project has not been build succesfully:

Screenshot of a Team System window showing a code analysis check-in policy violation when the project was not build succesfully (click for larger version)

1 Comment

<rant>

Checkout Windows Live in Firefox. Go read the comments about it on Robert Scoble's blog. Go read Joel on Software about it.

This is indeed a PR disaster. Announcing something web based at this day and age with Firefox support as an afterthought is pretty stupid.

And it is another branding disaster. I disliked the Windows Media Audio and Video branding. I dislike the Windows Blah Foundation branding. And now I dislike the Windows Live branding. Why? Because it sends a confusing message. Is WMA and WMV only supposed to be available on the Windows platform? This seamed to be the case for Windows Presentation Foundation, so I thought I could live with it. But then at PDC05 Microsoft announced Windows Presentation Foundation Everywhere (WPF/E). If it is supposed to be available everywhere, why brand it with Windows?!

.NET suffered from serious branding misuse in the past. Remember every MS server product getting the .NET label stuck on it, even if it had almost nothing to do with the .NET Framework. Since then Microsoft has backed off from using .NET in product names. Did you notice it has even disappeared from the Visual Studio product name: it's Visual Studio 2005 and not Visual Studio .NET 2005.

Maybe Microsoft should completely drop the Windows term for the next version of its OS and just call it Vista.

</rant>

I like installing the latest and greatest software. One thing missing from the Visual Studio 2005 puzzle was Team Foundation Server Beta 3 Refresh (TFS).  

At home I have two computers available that both run Windows XP Professional. Both have 1 GB RAM. TFS only runs on Windows Server 2003 SP1. Because I want TFS to be portable for demo purposes I decided to install it in a virtual machine on my laptop.

 So I dug up a pre-existing clean Windows Server 2003 Virtual PC image, copied it over to my laptop, and installed the following things on it:

  • Windows Server 2003 SP1
  • All post-SP1 security updates
  • SQL Server 2005 Developer Edition (*)
  • SharePoint Services 2.0 with SP2
  • VS 2005 Team Foundation Server Beta 3 Refresh
  • VS 2005 Team Foundation Client Beta 3 Refresh

At home I don’t run an Active Directory, so I decided to try out TFS in Workgroup mode. I got two warnings from the SQL Server 2005 and the TFS prerequisite checkers, but those were to be expected. I could only allocate 700 MB for the VPC and that it is a tad too little for those two products. Everything installed without problems. The only thing I noticed is that TFS Setup suffers from the Microsoft Progress Bar Syndrome: the progress bar progresses steadily but hangs for minutes at the 99% mark.

 

Installing Team Foundation Client on the server gives you the Team Explorer in an otherwise empty Visual Studio 2005 Standard Edition IDE:

Screenshot of the about box for Team Explorer installed in otherwise empty Visual Studio 2005 IDE on a Team Foundation Server (click for larger version)

Since I had already installed Visual Studio 2005 Team Suite with the Team Foundation Client, the next step was connecting to TFS. This worked without any login boxes, because I had configured local accounts with the same username and password on both the client and the server. This account is a local administrator on the server, and as such is automatically a member of the Team Foundation Administrators.

After connecting I created a new Team Project. This is the result:

 

My first Team Project in Team Foundation Server Beta 3 Refresh (click for larger version)

Thank you Microsoft for a job well done. Installing TFS is a breeze.

 

 (*) Don’t forget to configure remote connections it if you choose this edition.

Through this blog post I just noticed that a new white paper on Windows Presentation Foundation ("Avalon") is up on the Vista Developer Center on MSDN.

The paper provides a very good overview of all the different features and aspects of WPF. It focuses more on the whys than the hows. Like why Microsoft has decided to build a new unified presentation platform to supersede GDI and DHTML.

On a side note: The homepage of the Vista Developer Center has an RSS feed, but strangely enough the last entry on the feed dates back to September 14, 2005. What's the point of having an RSS feed, when it's not up to date?! The MSDN Just Published RSS feed does have recent entries, but does not include the WPF white paper.