Computer Science I / Integrated Programming Synthesis
Practice question · Put in order

Order the tasks of building the word-frequency counter so that each one can be tested as soon as it is written.

Hints
  1. Each function consumes what the previous one produces, so it cannot be tested before that one exists.
  2. Integration testing is only possible once there is something integrated to test.
Show the answer
  1. Write and test a function that splits a string into lower-case words
  2. Write and test a function that turns a list of words into a word-to-count dictionary
  3. Write and test a function that returns the ten highest counts from that dictionary
  4. Wire the three functions together into one pipeline
  5. Write an integration test that runs the pipeline on a small file with a known answer
Why

Building along the direction of data flow means every function can be unit-tested the moment it is written, using real output from the stage before. The integration test comes last because it exercises the interfaces, which only exist once the pieces are wired together.

Read the lesson: Integrated Programming Synthesis →

Practise Integrated Programming Synthesis

The app has 5 more questions on this lesson, and keeps your place in the course. Computer Science I is free to start.

More questions on Integrated Programming Synthesis