Possible Duplicate:
.net 4.0 Code Contracts. When to use? When are they a waste of time?
I started to read the full documentation of the .NET Code Contracts and I noticed that you can specify the compiler not to emit the code corresponding to your contracts. But I was wondering WHY someone would want to do that?! I mean, from the documentation, code contracts are about specifying pre / post / invariants about your code.
Looking at another question .net 4.0 Code Contracts. When to use? When are they a waste of time?, it seems that contracts should guard against invalid state of an object, but then again, why would I want to disable them! In doing so, wouldn't I open the door for a mountain of problems?
Should they be used as business validation, like making sure that a startDate <= endDate
or should I use the good old if-then-throw for business? If I disable the code contracts my class could now be in an invalid state.
So my question remains, why would I want to disable code contracts?