After stumbling with the latest install of Orcas, I loaded up the Silverlight 1.1 chess demo and was blown away with the poor quality of the coding style used in the demo. I’m at a total loss as to how a public demo comes out like this. It truly saddens me because for every 1 shitty demo Microsoft puts out, it probably takes 100 good ones to even out.
Am I being too harsh? Judge for yourself:
Multiple public types per file which is a direct violation of Microsoft’s INTERNAL Design Guidelines.
The namespace is “Chess”, which also violates Microsoft’s Design Guidelines.
The boardui.cs, browser.xaml and default.html.js files are all lowercase – all other files are PascalCased
Some simple getters are written in a single line, others over multiple lines
Some types and members rely on implicit visibility (don’t specify private/internal/public), others specify it. I don’t even know what the default type is…isn’t it internal for classes and private for fields?
Fields are spread all over…most are at the top of the class definition, some are defined above a method half way down.
Single line case statement which violates Microsoft’s Internal design guidelines
Classes with only static members that aren’t sealed and don’t have a private constructor (or, in 2.0, aren’t marked as static)
An unbelievable amount of SET-only properties (again, like most of these, violates Microsoft’s own design guidelines)
Within the same method, some fields are accessed with “this.” others aren’t
Some 1 line IF’s/Loops have braces…some don’t
Properties that call fairly expensive methods
Some usings are declared inside the namespace, some declared outside
Many if statements would benefit from Guard Clauses and Decompose Conditional refactoring
Poor use of #regions and very little of them
There’s certainly more. Many of the items above (especially #1 and #6) make the sample very hard to read. Running the project through FxCop came up with 143 issues.
I want to cry.