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: .NET