-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2069a4e
commit ad51aa9
Showing
1 changed file
with
18 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,20 @@ | ||
# synergy.contracts - a programming by contract C# library | ||
|
||
Design by contract (DbC), also known as contract programming, programming by contract and design-by-contract programming, is an approach for designing software. | ||
Design by contract (DbC), also known as contract programming, programming by contract and design-by-contract programming, is an approach for designing software. In software words - if a class provides some functionality, through a method, it expects that certain criteria should be met - the method has a contract. When 'client' does not meet the contract of 'supplier' it will receive an exception. | ||
|
||
## development phase | ||
|
||
DbC help us develop more reliable software. It is one of the basic principles of clean code programming. During the development phase when we integrate components (simply: when we call method of another class) we may violate the contract and receive the exception, but this is what it is for. If you encounter such case, you simply need to conform the contract of the 'supplier' class. | ||
|
||
Now, let's quit yapping and show some hello world sample: | ||
|
||
```C# | ||
[NotNull, Pure] | ||
public static Contractor CreatePerson([NotNull] string firstName, [NotNull] string lastName) | ||
{ | ||
Fail.IfArgumentEmpty(firstName, nameof(firstName)); | ||
Fail.IfArgumentEmpty(lastName, nameof(lastName)); | ||
|
||
throw Fail.Because("Not implemented yet"); | ||
} | ||
``` |