Has anyone implemented the Enterprise Library VAB along wtih Code Contracts in .NET 4.0?
If so, can you share some insights? Did it help in performance? Any other factors to be considered?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Both frameworks have a different scope so they could easily be used in the same project. However, you’ll have to prevent using Code Contracts in your domain entities. When you do this, all callers must ensure that they don’t set invalid values (a compile time error will occur when you do this). With Validation Application Block however, your entities must be allowed to have an (temporarily) invalid state. Otherwise VAB is unable to ever detect invalid objects.
Let me put it otherwise, Code Contracts is meant to prevent programming errors, not user errors and it gives compile time support for this. VAB prevents user errors, not programming errors* and gives runtime support for this.
*Okay, VAB could also be used for programming errors (and in fact, I do use it myself in this way) but main scenario is user input IMO.