CSE 2221 - Contracts

Contracts

25 October 2022

OSU CSE

1

Contract Details

? Contracts in the APIs for OSU CSE components include these important features:

? Parameter modes ? Two stipulations:

? Parameter names in requires and ensures clauses always stand for the object values, never the reference values, of the corresponding arguments to a method call

? Reference-type arguments are always non-null

25 October 2022

OSU CSE

2

Contract Details These are local decisions that apply to OSU CSE components' contracts; there are no industry

? Contracts in the APsItsanfdoarrdOs S(yUet)CthSatEgovern how components include thestoewimritepcoornttaranctts. features:

? Parameter modes

? Two stipulations:

? Parameter names in requires and ensures clauses always stand for the object values, never the reference values, of the corresponding arguments to a method call

? Reference-type arguments are always non-null

25 October 2022

OSU CSE

3

Parameter Modes

? There are four parameter modes, each of which indicates a possible way that a method might change the value of the corresponding argument

? Parameter modes help us in three ways:

? They concisely summarize which arguments might have their values modified by a call

? They make requires/ensures clauses shorter

? They allow us to perform "consistency checks" of contracts against certain simple errors

25 October 2022

OSU CSE

4

Parameter Modes

? There are four parameter modes, each of which indicates a possible way that a method might change the value of the corresponding argument

?MPodaersaamreelitseterdmfoor tdhee sforhmeallp us in three ways:

pa?raTmheetyercs,oinncilsuedilnygstuhmism, arize which arguments bumt aigchtutahllyavaepptlhy etoir tvhaeilrues modified by a call

cor?reTshpoenydimngakaerguremqeunitrsefso/reansures clauses shorter c?alTl,hinecyluadlilnogwthuesretocepiveerr.form "consistency checks" of contracts against certain simple errors

25 October 2022

OSU CSE

5

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download