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.

Showing a random 20 of 50 problems.

Example 1

medium
A system has modules that all directly call each other (full mesh) of 55 modules. How many directed dependency pairs is that, and is that desirable?

Example 2

medium
If you change a function's internal algorithm but keep its inputs and outputs identical, must callers change?

Example 3

easy
Structuring a program as independent self-contained units each doing one task is called ____ design.

Example 4

easy
True or false: a module that does one well-defined task is said to have high cohesion.

Example 5

challenge
Two modules share a global mutable variable to communicate. Explain why this is worse than passing data through an interface, in coupling terms.

Example 6

medium
A 500-line module handles login, logging, and email. Which design principle does it violate?

Example 7

hard
A 4-module system has cyclic dependencies: A->B->C->D->A. Why is this risky, and propose a fix.

Example 8

medium
A team of 3 developers must build an online quiz: auth, question bank, scoring. Which modular split lets the 3 work in parallel with minimal blocking?

Example 9

medium
A program duplicates the same 30-line date-parsing block in 5 places. According to modular design, what should you do?

Example 10

easy
A system has modules M1,M2,…,M7M_1, M_2, \ldots, M_7. How many modules in total?

Example 11

easy
Modules communicate through clear ____ rather than touching each other's internals.

Example 12

medium
A library exposes 30 public functions but uses 200 private ones internally. The 30 public ones form what?

Example 13

challenge
A monolith of 100,000 lines is split into 20 modules of about 5,000 lines each, with average dependency degree 3. Estimate edges and contrast with full mesh.

Example 14

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 15

easy
A module's public list of inputs, outputs, and callable functions is called its ____.

Example 16

medium
Why does modular design make debugging faster?

Example 17

hard
A program has 10 modules. After a refactor, dependency edges drop from 45 to 12. Describe what likely changed and why it matters.

Example 18

challenge
You must add a new payment method. With high cohesion and loose coupling, what is the ideal scope of code change, and why?

Example 19

challenge
Design a 5-module split for a streaming music service: playback, library, recommendations, billing, auth. State each interface and one cross-module call.

Example 20

easy
Can a well-designed module be replaced without rewriting the rest of the system, if its interface stays the same?