I saw an awesome demo of C# Code Contracts and I want to start implementing them into may code. I wish I had them in my code already. Where does one start?
I failed to take away any printed materials from the demo. Any suggested reading?
Any suggestions for a beginner with Code Contracts?
Thanks in advance for your help.
I'd start with this Wiki which describes Design by Contract. Then dive into the documentation on MS' implementation. To actually work it into your code, I suppose you could start almost anywhere, but maybe start with areas that are least likely to have an impact. So maybe add some Contract.Requires to ctor arguments, if appropriate. When you're more comfortable, you can add them to interfaces, but be aware this may blow things up... but in a good way. Errors or warnings mean you're violating DbC, and likely the Liskov Substitution Principle.
The user manual provided at the Code Contracts project page, gives a very good description of how to use and the possibilities of Code Contracts.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With