Suppose these three dogs are working on a group project:
They get together to write the main program. Here it is:
getInput, Dusty writes
computeShipping, and Ned writes
outputWebPage. Since they have the signatures of each sub, their subs shouldn’t step on each other.
But… how can Dusty write
computeShipping, when Lucky hasn’t finished
That’s where stubs come in. They’re fake subs, that have the same signature as a real sub, without the actual code.
Dusty is writing the processing code, which can’t run without data from
getInput. So she writes a stub:
computeShipping. She can change the constants in the stub, to see how
Ned, who’s writing the output sub, writes a stub for
computeShipping. Then he can get on with his work.
When they’re all done, they can put their subs together, and test the whole program.
A stub is a fake sub. It has the same signature as a real sub, without the actual code.