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
mediumA system has modules that all directly call each other (full mesh) of modules. How many directed dependency pairs is that, and is that desirable?
Example 2
mediumIf you change a function's internal algorithm but keep its inputs and outputs identical, must callers change?
Example 3
easyStructuring a program as independent self-contained units each doing one task is called ____ design.
Example 4
easyTrue or false: a module that does one well-defined task is said to have high cohesion.
Example 5
challengeTwo modules share a global mutable variable to communicate. Explain why this is worse than passing data through an interface, in coupling terms.
Example 6
mediumA 500-line module handles login, logging, and email. Which design principle does it violate?
Example 7
hardA 4-module system has cyclic dependencies: A->B->C->D->A. Why is this risky, and propose a fix.
Example 8
mediumA 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
mediumA program duplicates the same 30-line date-parsing block in 5 places. According to modular design, what should you do?
Example 10
easyA system has modules . How many modules in total?
Example 11
easyModules communicate through clear ____ rather than touching each other's internals.
Example 12
mediumA library exposes 30 public functions but uses 200 private ones internally. The 30 public ones form what?
Example 13
challengeA 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
mediumList 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
easyA module's public list of inputs, outputs, and callable functions is called its ____.
Example 16
mediumWhy does modular design make debugging faster?
Example 17
hardA program has 10 modules. After a refactor, dependency edges drop from 45 to 12. Describe what likely changed and why it matters.
Example 18
challengeYou must add a new payment method. With high cohesion and loose coupling, what is the ideal scope of code change, and why?
Example 19
challengeDesign a 5-module split for a streaming music service: playback, library, recommendations, billing, auth. State each interface and one cross-module call.
Example 20
easyCan a well-designed module be replaced without rewriting the rest of the system, if its interface stays the same?