Functions and decisions

Create reusable behaviour and explicit decision rules

Operational rules rarely consist of one uninterrupted calculation. They must classify cases, enforce boundaries, and reuse the same behaviour for many records. Functions and conditions turn those requirements into small units with clear responsibilities.

This part focuses on contracts: what a function receives, what it promises to return, and how it behaves at boundaries or with invalid input. Clear contracts make code easier to test, combine, debug, and review.

Learning objectives

By the end of this part, you will be able to:

  • define a function with meaningful parameters, a clear return value, and a focused responsibility;
  • write a function contract that states permitted inputs, expected behaviour, and boundary conditions;
  • translate decision tables and operational rules into readable conditional logic;
  • distinguish mutually exclusive cases and explain the effect of rule order;
  • compose several small functions into a larger calculation;
  • design normal, boundary, invalid, and discriminating tests; and
  • use error messages, traces, and tests to locate and correct a defect.
NoteRelease status

This page previews Module 4. Canvas announces when its detailed chapters become available on the public course site.