A program is a set of instructions written in a particular language and run in a particular environment. In this course the language is Java. Before the language matters, though, two ideas matter more.
A specification (or "spec") says what must be true when the task is done, and under what starting conditions. It describes the result, not the steps.
An algorithm is a precise, step-by-step procedure that produces the result. It says how.
| Specification | Algorithm |
|---|
| Answers the question | What counts as a correct result? | What exact steps produce it? |
| Example | "The 5 returned books end up on shelf 2, spines facing out, in call-number order." | "1. Pick up the leftmost book on the cart. 2. ..." |
| You check it by | Looking at the finished result | Following the steps exactly |
| How many versions? | One required result | Often many different algorithms work |
Every task has inputs, the things you are given at the start, and outputs, the things the task must produce. An output does not have to be printed text. If the task is "arrange the chairs in a circle," the arranged chairs are the output.
The line between what the task receives and what it must deliver is the task boundary. Anything outside the boundary, such as how the inputs got there or what happens to the output later, is not part of the job.

A spec is complete when two careful people checking the same result would always agree on whether it is correct. That usually means the spec names:
- The pieces. Which items, words or numbers appear in the result.
- The arrangement. Order, spacing, separators, line breaks and orientation (which way up, which way facing).
- The closing conditions. What must be true at the end: lid closed, hand empty, spare spot empty again.
- What must not change. For example, "no token may be lost or created."
The difference between pieces and arrangement trips up many students. "ant zoo" and "zoo ant" contain the same pieces in a different arrangement. If the spec says "the first word, one space, then the second word," only one of them is correct. The same goes for line order: three lines that contain all the right words in the wrong order fail a spec that names the order.
A teacher asks for a program that will "make a seat tag for a student." Today's student has the last name Okafor and seat number 12.
- Find the inputs. There are two: a last name (Okafor) and a seat number (12).
- Find the output. One line of text, the tag.
- Name the pieces. The tag must contain the name and the number. That alone is not enough, because "12 Okafor," "Okafor12" and "Okafor / 12" all contain both pieces, and they are different outputs.
- Name the arrangement. Choose one rule and state it: the name, then one space, then the capital letter S, then the seat number. For these inputs the tag is
Okafor S12.
- Write the rule for every allowed input, not just this one. For any last name with no spaces and any seat number from 1 through 40, output the name, one space, the capital letter S, then the seat number in digits, and nothing else.
Check: hand the spec to two friends with a new input, say Lin and seat 7. Both should write Lin S7 and nothing else. If either friend has to ask "which comes first?" or "is there a space?", the spec is not finished.
The trap: writing the spec for only the example you were shown, such as "output Okafor S12." That is not a rule. It is wrong for every other student.
Quick check 1. A spec says: "Output the city and the temperature." For the inputs Denver and 18, write two different outputs that would both satisfy this spec. Then add one sentence that makes the spec complete.