Assertions in design by contract: Difference between revisions

m
added whitespace before the TOC, added a Task (bold) header.
(→‎{{header|Java}}: added Java)
m (added whitespace before the TOC, added a Task (bold) header.)
Line 1:
{{draft task}}
{{draft task}}According to [[wp:Assertion_(software_development)#Assertions_in_design_by_contract|Wikipedia]]; Assertions can function as a form of documentation: they can describe the state the code expects to find before it runs (its preconditions), and the state the code expects to result in when it is finished running (postconditions); they can also specify invariants of a class.
 
{{draft task}}According to   [[wp:Assertion_(software_development)#Assertions_in_design_by_contract|Wikipedia]]; Assertions  assertions can function as a form of documentation:   they can describe the state the code expects to find before it runs (its preconditions), and the state the code expects to result in when it is finished running (postconditions);   they can also specify invariants of a class.
 
 
;Task:
Show in the program language of your choice an example of the use of assertions as a form of documentation.
<br><br>
 
=={{header|D}}==
D has exceptions, errors and asserts. In Phobos there is also an enforce(). D has pre-conditions and post conditions, and struct/class invariants. Class method contracts should work correctly in object oriented code with inheritance.