Friday, November 04, 2005 3:49 PM Erwyn van der Meer

The Quality of Microsoft Sample Code

While playing with the Code Analysis in Visual Studio 2005 Team System I decided to try it out on some of the sample apps shipped by Microsoft. My first victim was the Personal Web Site Starter Kit. This sample app is shipped in all Visual Studio 2005 editions including the Professional Edition.

This app can be created by choosing the menu-item File | New | Web Site and selecting the appropriate web site template. Choose C# as the language. After the solution is created right-click the web site in the Solution Explorer and choose the Run Code Analysis on Web Site context menu-item. Be prepared for a list of 48 warnings!

Of course not all warnings indicate serious errors but I think it indicates some sloppy coding and a lot of errors can be fixed very easily. I am sad that Microsoft still ships such sample apps that set a bad example to developers by violating Microsoft's own coding guidelines.

One of the most silliest coding mistakes is the signature of these two methods (from the same class PhotoManager):

public static Stream GetFirstPhoto(int albumid, PhotoSize size)

public static void EditAlbum(string Caption, bool IsPublic, int AlbumID)

Could this sample app have been produced by a VB developer who is not aware of the casing guidelines for method parameters?!  So I checked out the VB version as well. It suffers from the same problems. Strangely enough the code analysis now gives 54 warnings.

Filed under:

# re: The Quality of Microsoft Sample Code

Friday, November 04, 2005 6:31 AM by Jan Schreuder

LOL. Before you know it, someone might start the C# is better then VB discussion again, based on these results ;-)

I found similar violations FxCop on code generated by VS2003. Weird indeed.

# re: The Quality of Microsoft Sample Code

Friday, November 04, 2005 11:18 AM by Patrick Wellink

I won't start a discussion again....

I know how stubborn c# programmers are... it's useless trying to talk sence into them....

But my guess is....

It was written by a poor C# programmer ( probably some java dude before he started with cool .net stuff)

And then badly ported to VB.


And hey .......

It just tells you that all those 'nice' features that MS puts into their software isn't used by their own programmers....

Makes you think how usefull they really are ......

# ASP.NET 2.0 Club Web Site Starter Kit

Monday, November 07, 2005 12:41 PM by Erwyn van der Meer

How to get the Club Web Site Starter Kit to work if Microsoft has not yet released a version working on SQL Server 2005 RTM.

# ASP.NET 2.0 Club Web Site Starter Kit

Saturday, January 21, 2006 4:48 AM by Erwyn van der Meer

How to get the Club Web Site Starter Kit to work if Microsoft has not yet released a version working on SQL Server 2005 RTM.