Practice Modular Design in CS Thinking

Use these practice problems to test your method after reviewing the concept explanation and worked examples.

Quick Recap

Modular design is the practice of structuring a program as a set of independent, self-contained modules, each responsible for a single, well-defined task. Modules communicate through clear interfaces, making the system easier to build, test, debug, and maintain.

LEGO blocksβ€”each piece does one thing and connects to others in standard ways.

Example 1

easy
A student writes a 200-line program as one big block of code. Suggest how they could improve it using modular design.

Example 2

medium
A game program needs: a menu system, a game loop, a scoring system, and a high-score table. Design a modular structure showing how these components interact.

Example 3

medium
List three benefits of modular design and give a specific example of each benefit in the context of a team building a web application.

Example 4

hard
Explain the concepts of coupling and cohesion in modular design. Why do we want low coupling and high cohesion? Give an example of a poor design that violates these principles.