CPSA Designing Building Blocks 4 — Questions and Answers
Question 1: Which design principle helps prevent building blocks from becoming overly large by limiting their public interfaces?
- Interface Segregation Principle (Correct answer)
- Dependency Inversion Principle
- DRY Principle
- Law of Demeter
Correct answer: Interface Segregation Principle
The Interface Segregation Principle states that clients should not be forced to depend on interfaces they do not use, promoting smaller, focused interfaces.
Question 2: A 'black box' perspective on a building block means that:
- The block processes encrypted data
- Only the block's interface and behavior are visible, not its internals (Correct answer)
- The block has no external dependencies
- The block is implemented in an unreadable compiled language
Correct answer: Only the block's interface and behavior are visible, not its internals
A black box view exposes only what a block does (its interface and behavior) without revealing how it does it internally.
Question 3: What is the relationship between 'abstraction level' and building block granularity in architecture documentation?
- Higher abstraction levels show finer-grained blocks with more detail
- Higher abstraction levels show coarser-grained blocks with fewer details (Correct answer)
- Abstraction level and granularity are unrelated
- Lower abstraction levels always map to fewer building blocks
Correct answer: Higher abstraction levels show coarser-grained blocks with fewer details
At higher abstraction levels, building blocks represent larger, coarser-grained components; detail increases as you zoom into lower levels.
Question 4: Which of the following is a CORRECT way to express that Building Block A depends on Building Block B?
- A provides an interface that B implements
- A's required interface matches B's provided interface (Correct answer)
- B's required interface matches A's provided interface
- A and B share the same internal data model
Correct answer: A's required interface matches B's provided interface
A dependency from A to B means A requires a service that B provides — A's required interface is fulfilled by B's provided interface.
Question 5: In the context of building block design, what does 'stable dependency principle' prescribe?
- Frequently changing blocks should depend on stable blocks (Correct answer)
- Stable blocks should depend on volatile blocks
- All blocks should be equally stable
- Blocks should avoid depending on external libraries
Correct answer: Frequently changing blocks should depend on stable blocks
The Stable Dependency Principle states that dependencies should point toward more stable components to limit change propagation.
Question 6: Which technique is MOST appropriate for decoupling two building blocks that must communicate asynchronously?
- Direct method calls via shared interfaces
- Message queues or event buses between the blocks (Correct answer)
- Shared global variables
- Remote procedure calls with synchronous return values
Correct answer: Message queues or event buses between the blocks
Asynchronous message queues or event buses decouple sender and receiver in both time and knowledge, enabling independent evolution.
Question 7: What risk does a building block with too many responsibilities (a 'god class') pose to a software system?
- It improves performance by centralizing logic
- It becomes a bottleneck for changes affecting many unrelated features (Correct answer)
- It reduces the total number of dependencies in the system
- It simplifies testing by consolidating behavior
Correct answer: It becomes a bottleneck for changes affecting many unrelated features
God classes accumulate responsibilities over time, causing many unrelated changes to collide in one place, slowing development and increasing defect risk.
Which design principle helps prevent building blocks from becoming overly large by limiting their public interfaces?