Skip to content
← Learning guide

The Function

← Back to study results
Other download formats

Illustrated study

A calculation embodied in a tool

A spiral slide rule invites a comparison between a physical calculation procedure and a reusable software function.

A cylindrical slide rule with densely printed scales, metal pointers and a wooden handle, displayed in a museum.

Figure 1 · Photographed 4 August 2013

Keuffel & Esser Model 1742, Fuller Spiral Slide Rule

Look for the scales, pointers and parts that can move. To explain a calculation, you would need to specify what is set, which operation is performed and how the result is read. Apply those same questions to a software function's inputs, behavior and output. The instrument is a comparison, not a depiction of program code.

Daderot (photographer) · MIT Museum · MIT Slide Rule Collection
Photograph by Daderot · CC0 · via Wikimedia Commons

View full size ↗Download image
Collection record and reuse rights

Display copies are resized and compressed. Source and license links apply to the image above.

Explore more museum and archive collections →

Software · The Function

Write a contract before an implementation

Use a simple example to distinguish the information a function receives from the result it promises. Keep side effects visible.

Try this

Describe an imaginary function's input, output and failure cases in plain language, then supply three examples.

Reflect

Which input would reveal an ambiguity in the contract?

Take it further · optional follow-up

Ask someone to predict the output for a new example from your contract alone. Clarify any ambiguity before describing an implementation.

Compare with another activity · Property & Renewal

The Handover: Design a useful record →

Prepared study prompt · not an editor-reviewed research article