Questions tagged [code-contracts]
Code Contracts provide a language-agnostic way to express coding assumptions in .NET programs. The contracts take the form of preconditions, postconditions, and object invariants. Contracts act as checked documentation of your external and internal APIs.
13 questions
0
votes
0
answers
431
views
Client-Server Coupling in gRPC vs REST
Quoting this article - The Other key differences: gRPC vs. REST section (client server coupling):
Client-server coupling
REST is loosely coupled, which means the client and the server do not
need to ...
6
votes
6
answers
2k
views
Should I assert the preconditions of functions in a public API?
I am writing a library for some data structures in C that will be used in embedded systems. I have had issues designing and coming up with a solid error handling plan. This API is only subject to ...
9
votes
4
answers
3k
views
Handling changes in a event-driven microservice architecture
I'm doing an research-project where I'm researching the options to handle changes in an event-driven microservice architecture.
So, let's say we got an application where we got four different ...
13
votes
6
answers
4k
views
Contract Based Programming vs Unit Test
I am a somewhat defensive programmer and a big fan of Microsofts Code Contracts.
Now I cannot always use C# and in most languages the only tool I have is assertions. So I usually end up with code ...
3
votes
4
answers
400
views
Why must the burden of proof rest with the caller and not the method of the class that is being called?
Michael Perry states in his Pluralsight course on Provable Code (transcript subscription only) that:
[T]he burden of proof rests with the caller
In a code contract, why must the burden of proof rest ...
10
votes
2
answers
651
views
code contracts/asserts: what with duplicate checks?
I'm a huge fan of writing asserts, contracts or whatever type of checks available in the language I'm using. One thing that bothers me a bit is that I'm not sure what the common practice is for ...
55
votes
10
answers
38k
views
Should a method validate its parameters? [duplicate]
Say you are designing a Square root method sqrt. Do you prefer to validate the parameter passed is not a negative number or do you leave it up to the caller to make sure the param passed is valid. How ...