I noticed that Microsoft named their code-contract-relative functions in .NET 4 in a strange manner.
They add "s" at the end of "require" and "ensure", so there are Contract.Requires() and Contract.Ensures(), but not at the end of "assert" and "assume", so there are Contract.Assert() and Contract.Assume(). The difference makes me a little confused.
In fact, my real problem is, I'm trying use code-contract in PHP, so I write something to imitate the "Contract" class in .NET 4. Since PHP has no build-in method to validate the type of parameters, I add a method to my own Contract class to do some validation. I choose the word "expect", because I think "expect parameter 'bar' to be string but..." is a common message when parameter type is wrong. And there comes the problem. Should I name my method Contract.Expect() or should I name it Contract.Expects()?
I'm from a non-english-speaking country, so sorry for my poor english. May be it's actually a english-language question, but I think only programmers can help me. So sorry for that if this question is not proper here.
I believe Ensures
and Requires
are describing what methods need and/or guarantee, whereas Assert
and Assume
are commands to the contract verifier.
Or in other words, the former two describe preconditions/postconditions about the method's outside interface, whereas the latter two are just metadata to help the contract verifier do its job for you inside the method. One is relevant to the user, but the other one isn't.
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