Sixteen weeksscene 5 / 34~3 min
Decisions and repetition
Four shapes, arranged forever.
Look back at the box from last scene, and notice something that stays true from that little box all the way up to the eleven-year codebase it lives in: nearly everything is built from about four shapes, arranged forever. Four.
The named recipe
deliver_cheer is a functionConcept · lights on your mapfunctionA named, reusable group of instructions that does one job. It can take inputs, do work, and hand back a result. Input, processing, output, at the scale of a paragraph. Most code is functions calling functions.: a named piece of the program that does one job and can be asked to do it from anywhere. You know its shape already. It is input, processing, output, shrunk to a paragraph, and a codebase is thousands of these calling each other in chains.
Its inputs have two names, and engineers keep them straight with some ceremony. The labelled slot in the definition, cheer, runner, is a parameterConcept · lights on your mapparameterA function’s named input slot as written in its definition. The slot itself, as distinct from the value put into it, which is the argument.. The actual value that arrives in the slot, this cheer from Molly, this runner 11208, is an argumentConcept · lights on your mapargumentThe actual value supplied when a function is called. The thing placed in the slot, where the parameter is the slot itself.. Slot, and thing in slot. Pedantic until a bug report says the function got the wrong argument. Then it is precision.
The fork and the wheel
The if runner.finished line is a conditionalConcept · lights on your mapconditionalA structure that asks a true-or-false question and chooses which instructions run based on the answer. Every rule a product enforces becomes one of these somewhere.: a question with two roads out. Every rule this story has ever mentioned lives as one of these somewhere. One entry per person is a conditional. The birthdate check is a conditional. Dana’s cheers-after-the-finish-are-dropped is the very conditional on your screen, and product debates, traced far enough down, are usually two people arguing about which road an if should take.
And when a cheer must reach every follower of a runner, the code does not say it forty times. It uses a loopConcept · lights on your maploopA structure that repeats a group of instructions, often once for each value in a list: for each follower, deliver. How products handle “all of them” without writing code for each one.: for each follower, deliver. One sentence of code, any number of followers. Loops are how software faces a crowd of forty thousand with a straight face, and on race morning that is not a figure of speech.
Function, parameter and argument, conditional, loop. Four shapes. Finn’s Thursday version handles the happy Tuesday where everything goes right, and on Friday, Priya, the teammate at the next desk, asks the question that fills the next scene: what happens when it does not?
End of scene
This scene covers: function, parameter, argument, conditional, loop