Decomposition CS Thinking Example 4

Follow the full solution, then compare it with the other examples linked below.

Example 4

medium
Decompose building a class voting app into four modules, and identify one dependency between them.

Solution

  1. 1
    Step 1: Reasonable modules are: user interface, vote collection, vote tallying, and results display.
  2. 2
    Step 2: A key dependency is that results display depends on vote tallying, and vote tallying depends on vote collection being complete or updated.

Answer

Example modules: UI, vote collection, vote tallying, results display. Dependency: results display depends on the tally produced from collected votes.
Decomposition works best when each sub-problem has a clear responsibility and the dependencies between parts are explicit. That makes the overall system easier to build and test.

About Decomposition

Breaking a complex problem into smaller, independently-solvable parts that combine into a complete solution.

Learn more about Decomposition โ†’

More Decomposition Examples