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.

One thought on “The Quality of Microsoft Sample Code

  1. 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 ......

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *