Browsing the archives for the DbC tag.


Design by Contract for C#

Software

If the propeller on your beanie has slowed down and you need a little geekifying, try checking out Spec#. It’s an extension of C# that supports Design by Contract (or Programming by Contract for the litigious). You know — preconditions, postconditions, invariants, side effects.

For alternative views into DbC for C#, you might check out XC#, although it looks like it might be abandonware. Plus they use that weird “my word has an X in it so I’ll use that in the acronym” thing.

My own take: Spec# looks forbiddingly complex. I personally believe spending the extra time writing unit tests would not only wed the code to the contract(s), but also helps iteratively flesh out the design (”design a little, code a little“), which to my mind is just as beneficial.

No Comments