Free practice · ordering · medium

Practice

Design a small function

Order a reviewable function-design workflow.

Function contract trace

A caller supplies values and receives one defined result

  1. ContractDefine inputs, output, and failures
  2. ArgumentsEvaluate supplied values
  3. ParametersBind local names
  4. BodyRun focused local logic
  5. ReturnSend the result to the caller
  6. TestCheck the public contract

Keep argument evaluation, parameter binding, local state, return behavior, and external side effects visible at the function boundary.

Arrange in the correct order
  1. 1. Review names, side effects, and call-site clarity
  2. 2. Test normal, boundary, and invalid cases
  3. 3. Implement the smallest deterministic body
  4. 4. Define parameters, returned output, and invalid-input behavior
  5. 5. State one focused responsibility