Thursday, December 23, 2010

December Update of the Coding Guidelines for C# 3.0 and C# 4.0

I finally found some time to update the coding guidelines with some feedback I received since it’s original release in June this year. I’ve removed the following guidelines because I found that they were either very exotic or not general enough for most developers:

  • Avoid side-effects when throwing recoverable exceptions (AV1044)
  • Don’t make assumptions on the object’s state after raising an event (AV1050)
  • Adhere to the LINQ Design Guidelines for custom IQueryable implementations (AV1075)
  • Explicitly define the scope of a type or member (AV1551) because it is a duplicate of AV1501.

I also noticed that the Design Guidelines section is getting bigger with each new version, so I split up that section into three smaller sections. And because of that, I had to renumber the guidelines in the AV1025-1100 range as well. So what about the new guidelines?

Well, these are new ones:

  • Use an interface to support multiple implementations, not a base class (AV1004)
  • Use an interface to decouple classes from each other (AV1005)
  • Avoid bidirectional dependencies (AV1020)
  • Classes should have state and behavior (AV1025)
  • Avoid mutual exclusive properties (AV1110)
  • Don’t expose stateful objects through static members (AV1125)
  • Use exceptions instead of return codes for reporting failures (AV1200)
  • Don’t use nested loops in a method (AV1532)
  • Consider abstracting an external dependency or 3rd party component (AV1580)

As usual, you can download the latest version, its A4 cheat sheet, and Visual Studio 2010 rule sets at www.csharpcodingguidelines.com.

Saturday, December 11, 2010

A night of Silverlight, WPF, unit testing and Caliburn Micro

Last Thursday, me and my employer Aviva Solutions hosted the December edition of the DotNED user group in Leiden. And yesterday a shared my Silverlight reference architecture on this year’s last SDN Event. I gave two talks that evening and one last night and wanted to share my slides and example code from here.

Best Practices for Writing First Class Unit Tests
Slides, Example Code

Building Testable Silverlight and WPF applications using Caliburn Micro
Slides, Example Code

A Silverlight 4 Reference Architecture for LOB Applications
Slides, Example Code

Notice that you need Visual Studio 2010, the Silverlight 4 Tools and probably the Silverlight 4 Toolkit (but I’m not entirely sure about the latter).

If you have any questions, let me know.