Validation Application Block and .NET Code Code Contracts

Has anyone implemented VBA Enterprise Library along with code contracts in .NET 4.0?

If so, can you share some thoughts? Did it help in the performance? Any other factors to consider?

+3
source share
1 answer

Both frameworks have a different area, so they can be easily used in one project. However, you will need to prohibit the use of code contracts in your domains. When you do this, all callers must make sure that they do not set invalid values ​​(this produces a compile-time error). However, when using the application block for validation, your entities must be allowed to have a (temporarily) invalid state. Otherwise, VAB will not be able to detect invalid objects.

Let me put it another way: "Code contracts" are designed to prevent programming errors, not user errors, and this gives compile-time support. VAB prevents user errors, not programming errors *, and provides runtime support for this.

* , VAB ( ), IMO.

+5

Source: https://habr.com/ru/post/1737410/


All Articles