Group project

Suppose these three dogs are working on a group project:

Lucky Dusty Ned
Lucky Dusty Ned

They get together to write the main program. Here it is:

  1. Dim biscuits as Integer
  2. Dim frisbees as Integer
  3. Dim ropeMeters as Single
  4. Dim weight as Single
  5. Dim shipping as Single
  6. getInput biscuits, frisbees, ropeMeters
  7. computeShipping biscuits, frisbees, ropeMeters, weight, shipping
  8. outputWebPage biscuits, frisbees, ropeMeters, weight, shipping
Then they break up to work on their subs individually. Lucky writes 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 getInput?

Fake subs

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:

  1. Sub getInput(biscuits as Integer, frisbees as Integer, ropeMeters as Single)
  2.     biscuits = 12
  3.     frisbees = 3
  4.     ropeMeters = 3.4
  5. End Sub
Now she can write and test computeShipping. She can change the constants in the stub, to see how computeShipping runs.

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.