Code reviews are the norm in big tech companies. Alongside them: coding standards (ie style guide). Contracts are a great addition! Let's see how contracts help a team during code review.
Try these rules during code review:
* Contracts state what must be true about the inputs
* Contracts state what will be true about the outputs
* Contracts use declarative language, not procedural
* Contracts omit implementation choices, including sequence
* Contracts state when a subset of a type is used
* Contracts state how nulls are handled
* Contracts state what inputs or states trigger predictable failures
* Contracts identify any side effects
* Callers can understand the contract without reading the implementation
* State ubiquitous conditions as invariants
* Prefer simple contracts over complex ones
* Omit contracts only when caller cannot infer the wrong contract
* Align contracts with the contours of the problem
* Separate predicates, queries, and commands
References:
Better code reviews with Design by Contract, 2019, IEEE Software Magazine. [ Ссылка ]
Ещё видео!