Contract.Requires vs Contract.Require

I noticed that Microsoft named its code contract features in .NET 4 in a weird way.

They add "s" at the end of "require" and "provide", therefore Contract.Requires () and Contract.Ensures () exist, but not at the end of "assert" and "take", therefore there is Contract.Assert () and Contract .Assume (). This difference bothers me a little.

Actually, my real problem is that I am trying to use the contract code in PHP, so I am writing something to imitate the Contract class in .NET 4. Since PHP does not have a built-in method for checking the type of parameters, I am adding a method to my own class Contract to do some validation. I choose the word "wait" because I think that "expect the parameter" bar "to be a string, but ..." is a common message when the type of the parameter is incorrect. And there is a problem. Should I name my Contract.Expect () method or should I name it Contract.Expects ()?

I am from a country that does not speak English, so sorry for my poor English. Maybe this is actually a question in English, but I think that only programmers can help me. Sorry if this question does not fit here.

+8
source share
1 answer

I believe that Ensures and Requires describe which methods are needed and / or guaranteed, while Assert and Assume are contract verifier commands.

Or, in other words, the first two describe the prerequisites / postconditions about the external interface method, while the last two are just metadata to help the contract verifier do the work for you inside the method. One of them is related to the user, and the other is not.

+15
source share

All Articles