Methods, contracts and test cases: Representations and decisions
≈ 36 minMethods, contracts and test cases: Representations and decisions
A Java method gives one carefully defined job a name. Parameters state the inputs, a return value states the result, and a contract lets another programmer use the method without reading every line inside it.
Learning move. In this lesson, choose a diagram, table, trace or model that makes the decision visible.
Worked example. A calculateAverage method receives marks and returns one number. It should not also print a report, change a learner record and open a file: those are separate jobs that can be tested independently.
Which statement best reflects this lesson's method contract?
Write the key term for this lesson: method contract.
A school system needs a reliable next step. Which choice is most defensible for this topic?
A learner can repeat a definition from Methods, contracts and test cases: Representations and decisions. Which next task gives stronger evidence of mastery?

