Thursday, August 6, 2009

Coding Guidelines

Last night I presented to the Perth .Net Community on an upcoming tool called PEX. There were a couple of mentions in the talk of "allowable exceptions" backed up by mentions of the .Net Framework Guidelines.
I was asked by a few people afterward what the book was and whether I had presumably made these guidelines up ;)
I was under the impression that this book was widely read, so it is clearly not as common knowledge as i may have thought.
Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries (2nd Edition)
is a must read for .Net devs that are writing code that is consumable by others (ie anything that uses public or protected accessors)

I would highly recommend this as it also gives a lot of background as to "why" behind the recommendations. It is also nice to read the comment from authors of certain .Net framework as they point out many things including their mistakes.

The books is made available online for free (not sure if it is in its entirety) at MSDN here

The allowable exception was in reference to section 7.3.5 (page 237) or a cut down version here

Oh, the links to the Pex stuff are here:


Thanks to everyone who came (especially those who bought beers afterwards) ;)

2 comments:

Peli said...

Could you share the slidedeck or feedback? (Peli, a Pex developer on vacation)

RhysC said...

Hey Peli
Yeah i think anyone playing with PEX knows who you are!
Just to let you know i was using VS2008 with the latest download, with out TFS integration
There were a few things that I/We thought of:
1- my major concern is that PEx will be used in correctly as a replacement to TDD. this has nothing to with the development of Pex, but a concern nonetheless.
2 - Love the TFS integration and the explicit notification of what PEX is planning on doing, very considerate.
3 - Smart Object Creation does not seem to be too smart. I use DI everywhere, why can Pex not just use Stubs generated to be parameters to my ctors? It passes nulls but cant figure out the stubs it just created is a valid input to the ctor!(?)
4- it crashed and stalled a fair bit.. possible an OS/PC problem.

If the object creation aspect was fixed it would find it a usable solution to be a good safety net for commercial code, however withnout this it feel like to much work to test already tested code.
Also the addition of a good contract API (ie designer/compile and run time checks) would alleviate many of the bugs that PEX found in my code.

cheers