State Hidden Assumptions as Constraints
Scenario
A rule says "A reader may hold up to 3 books." Two teammates disagree on whether an overdue book blocks borrowing.
Try it yourself
Compare each assumption against an explicit contract constraint.
| Case | Result |
|---|---|
| Assume every reader has whole-number books and no overdue items | Select a choice above to see what happens. |
| Constraint: borrowedCount is a non-negative integer; checkout requires borrowedCount < 3 | Select a choice above to see what happens. |
| Constraint: overdue status is out of scope for v1 and ignored by this function | Select a choice above to see what happens. |
Reveal the explanation
- Assume every reader has whole-number books and no overdue items
Risky hidden assumption. Another developer or AI agent may enforce a different rule.
- Constraint: borrowedCount is a non-negative integer; checkout requires borrowedCount < 3
Clear numeric constraint. Negative counts and fractions are explicitly excluded.
- Constraint: overdue status is out of scope for v1 and ignored by this function
Clear scope boundary. Both teammates know not to invent an extra parameter.
Writing constraints explicitly—including what is out of scope—prevents silent mismatches between specification, code, and tests.
Your turn
List two explicit constraints for a study-room seat count input (e.g., whole integer, maximum room capacity 12).
Common mistake Leaving out whether zero seats or fractional numbers like 1.5 are allowed.
Check your work
Two written constraints naming allowed type and numeric bounds.
Quick check
This browser could not save your progress. Changes last until you leave the page.