Chapter 24: Quiz
Test your understanding of software architecture concepts. Each question has one best answer. Try to answer each question before revealing the solution.
Question 1
What best defines a "software architecture decision"?
A) Any decision made during software development B) A decision about which programming language to use C) A decision that is expensive to change once the system is built D) A decision made by a senior engineer
Show Answer
**C) A decision that is expensive to change once the system is built.** Architecture decisions are distinguished from other development decisions by their cost of reversal. Choosing a variable name is trivially reversible; choosing a database technology, communication pattern, or deployment model is not. This is what makes these decisions "architectural" -- they shape the system's future in ways that are difficult to undo.Question 2
Which of the following is NOT an advantage of a monolithic architecture?
A) Simple to develop and deploy B) No network latency between components C) Independent scaling of individual components D) Easy to debug (single process, single log stream)
Show Answer
**C) Independent scaling of individual components.** Independent scaling is an advantage of microservices, not monoliths. In a monolith, all components are deployed together, so scaling requires scaling the entire application even if only one component is under load.Question 3
A 3-person startup with a 4-month deadline should most likely choose which architecture?
A) Microservices with Kubernetes B) A well-structured monolith C) Serverless with event sourcing D) A distributed service mesh
Show Answer
**B) A well-structured monolith.** For a small team with a tight deadline, a monolith is almost always the best choice. It minimizes operational complexity, allows rapid iteration, and eliminates the overhead of distributed systems. The team can always decompose into microservices later if needed. Premature adoption of microservices is one of the most common architectural mistakes.Question 4
What does the Single Responsibility Principle (SRP) state?
A) A function should take only one parameter B) A class should have only one method C) A class should have only one reason to change D) A module should contain only one class
Show Answer
**C) A class should have only one reason to change.** SRP does not limit the number of methods or the size of a class. It requires that a class be focused on a single responsibility or concern, so that changes to one aspect of the system do not require modifications to unrelated code.Question 5
Which SOLID principle is violated when a subclass changes the behavior contract of its parent class?
A) Single Responsibility Principle B) Open/Closed Principle C) Liskov Substitution Principle D) Dependency Inversion Principle
Show Answer
**C) Liskov Substitution Principle (LSP).** LSP states that objects of a superclass should be replaceable with objects of a subclass without breaking the program. When a subclass changes the behavior contract (e.g., a `ReadOnlyList` that raises an error when `add()` is called), code that expects the parent's behavior will break.Question 6
In the context of dependency injection, what is "constructor injection"?
A) Injecting dependencies through setter methods after construction B) Passing dependencies as parameters to the class constructor C) Using a global service locator to find dependencies D) Hard-coding dependencies inside the constructor
Show Answer
**B) Passing dependencies as parameters to the class constructor.** Constructor injection is the most common and recommended DI pattern. Dependencies are provided when the object is created, making them explicit and ensuring the object is fully initialized before use. This contrasts with setter injection (post-construction) and service locator (implicit lookup).Question 7
What is the primary benefit of the Dependency Inversion Principle?
A) It makes code run faster B) It reduces the total number of classes C) It decouples high-level business logic from low-level infrastructure details D) It eliminates the need for testing
Show Answer
**C) It decouples high-level business logic from low-level infrastructure details.** DIP ensures that your business logic does not depend directly on databases, email servers, file systems, or other infrastructure. Instead, both depend on abstractions. This makes the business logic testable, portable, and adaptable to changing infrastructure.Question 8
In an event-driven architecture, what does the publish-subscribe pattern provide?
A) Guaranteed message delivery B) Synchronous communication between components C) Loose coupling between event producers and consumers D) Faster execution than direct function calls
Show Answer
**C) Loose coupling between event producers and consumers.** The primary benefit of pub/sub is decoupling. Publishers emit events without knowing who (if anyone) will handle them. Subscribers react to events without knowing who produced them. This enables independent development, deployment, and scaling of components. It does not inherently guarantee delivery or provide synchronous communication.Question 9
What is event sourcing?
A) Using events to trigger serverless functions B) Storing the sequence of events that led to the current state, rather than the current state itself C) Publishing events to a message queue for async processing D) Logging all API requests for debugging purposes
Show Answer
**B) Storing the sequence of events that led to the current state, rather than the current state itself.** Event sourcing stores every state change as an immutable event. The current state is derived by replaying all events. This provides a complete audit trail, enables temporal queries, and allows event replay with modified logic.Question 10
Which scaling strategy adds more servers running the same application?
A) Vertical scaling B) Horizontal scaling C) Database sharding D) Caching
Show Answer
**B) Horizontal scaling (scaling out).** Horizontal scaling adds more instances of the same application behind a load balancer. Vertical scaling (A) adds more resources to a single server. Sharding (C) and caching (D) are complementary strategies but are not the same as horizontal scaling.Question 11
What is the prerequisite for horizontal scaling of a web service?
A) Using a NoSQL database B) The service must be stateless C) The service must use microservices architecture D) The service must be written in a compiled language
Show Answer
**B) The service must be stateless.** A stateless service stores no data between requests -- all state lives in external stores (databases, caches). This means any instance can handle any request, allowing a load balancer to distribute requests freely across instances. Stateful services cannot be horizontally scaled because user sessions would be lost when routed to different instances.Question 12
In the cache-aside pattern, what happens on a cache miss?
A) The request fails with an error B) The application loads data from the database and populates the cache C) The cache automatically fetches data from the database D) The request is redirected to a different server
Show Answer
**B) The application loads data from the database and populates the cache.** In the cache-aside pattern, the application is responsible for managing the cache. On a miss, it queries the primary data store, stores the result in the cache for future requests, and returns the data to the caller.Question 13
What is an Architecture Decision Record (ADR)?
A) A database record storing system configuration B) A short document capturing the reasoning behind a significant design choice C) A log file recording all architectural changes D) A code comment explaining a design pattern
Show Answer
**B) A short document capturing the reasoning behind a significant design choice.** An ADR typically includes the context (why the decision was needed), the decision itself, alternatives considered with their pros and cons, and the consequences. ADRs serve as institutional memory, helping future developers understand not just what was decided, but why.Question 14
According to the RADIO framework for system design conversations with AI, what does the "O" stand for?
A) Output format B) Object model C) Operational constraints D) Optimization goals
Show Answer
**C) Operational constraints.** RADIO stands for Requirements, Actors, Data, Interfaces, and Operational constraints. The "O" captures real-world constraints like team size, budget, timeline, existing technology, and deployment environment -- factors that are critical for making practical architectural decisions.Question 15
What is Conway's Law?
A) The law that states software complexity grows quadratically with team size B) The observation that organizations design systems that mirror their own communication structure C) The principle that every module should have exactly one owner D) The rule that architecture documentation must be updated with every code change
Show Answer
**B) The observation that organizations design systems that mirror their own communication structure.** Conway's Law states that the structure of a software system will tend to reflect the organizational structure of the team that builds it. This has practical implications: if you want a microservices architecture, you need small autonomous teams; if you have one large team, you will tend to produce a monolith.Question 16
Which of the following is a disadvantage of serverless architecture?
A) High cost when idle B) Requires manual server management C) Cold start latency and vendor lock-in D) Cannot scale beyond a single server
Show Answer
**C) Cold start latency and vendor lock-in.** Serverless functions that have not run recently experience cold start delays. Additionally, serverless code is tightly coupled to the cloud provider's services and APIs, making migration difficult. Serverless actually has near-zero cost when idle (A is wrong), requires no server management (B is wrong), and scales automatically (D is wrong).Question 17
What does the Open/Closed Principle state?
A) Software should be open source and closed to proprietary extensions B) Files should be opened and closed properly to prevent resource leaks C) Software entities should be open for extension but closed for modification D) APIs should be open to the public but closed to unauthorized users
Show Answer
**C) Software entities should be open for extension but closed for modification.** OCP means you should be able to add new behavior (open for extension) without changing existing code (closed for modification). This is typically achieved through abstraction, inheritance, or composition -- for example, adding a new notification channel by creating a new class rather than modifying an existing switch statement.Question 18
In a system using event-driven architecture, what is a "dead-letter queue"?
A) A queue for events that have been successfully processed B) A queue for events that failed processing and need investigation C) A queue for events scheduled for future delivery D) A queue for events from deleted user accounts
Show Answer
**B) A queue for events that failed processing and need investigation.** A dead-letter queue captures events that handlers could not process, whether due to errors, malformed data, or unhandled event types. This prevents failed events from being lost and allows operators to investigate and retry them manually or automatically.Question 19
Amazon distinguishes between Type 1 and Type 2 decisions. Which statement is correct?
A) Type 1 decisions are easy to reverse; Type 2 decisions are difficult to reverse B) Type 1 decisions are irreversible and deserve extensive analysis; Type 2 decisions are reversible and should be made quickly C) Type 1 decisions are made by individuals; Type 2 decisions are made by committees D) Type 1 decisions involve technology; Type 2 decisions involve people
Show Answer
**B) Type 1 decisions are irreversible and deserve extensive analysis; Type 2 decisions are reversible and should be made quickly.** This classification helps teams allocate their analysis effort appropriately. Type 1 decisions (choosing a database, defining a public API) are hard to undo and deserve careful deliberation. Type 2 decisions (choosing a logging library, naming a module) can be easily changed and should not be over-analyzed.Question 20
Which caching strategy writes to both the cache and the database simultaneously?
A) Cache-aside B) Write-through C) Write-behind D) Read-through
Show Answer
**B) Write-through.** In write-through caching, every write operation updates both the cache and the primary data store simultaneously. This ensures strong consistency between cache and database but adds latency to writes. Cache-aside puts the burden on the application; write-behind defers database writes asynchronously.Question 21
What is the "Dependency Rule" in Clean Architecture?
A) Dependencies should be minimized by using fewer third-party libraries B) Dependencies should flow inward, from outer layers toward the domain core C) Dependencies should be listed in alphabetical order in import statements D) Dependencies should be updated to the latest version at all times
Show Answer
**B) Dependencies should flow inward, from outer layers toward the domain core.** In Clean Architecture, outer layers (UI, database adapters, API routes) depend on inner layers (business logic, domain models), never the reverse. The domain core should have zero knowledge of databases, frameworks, or external services. This ensures the core business logic is portable and testable.Question 22
Which of the following is the strongest indicator that a module boundary is in the wrong place?
A) The module has more than 10 files B) Changes to one module frequently require simultaneous changes to another module C) The module uses a third-party library D) The module has a long name
Show Answer
**B) Changes to one module frequently require simultaneous changes to another module.** If changes to module A consistently require changes to module B, it means the boundary between them splits a single responsibility. This is called "shotgun surgery" and indicates either the modules should be merged, or the boundary should be redrawn so that related functionality is on the same side.Question 23
A system needs to handle 50,000 concurrent read requests per second, but only 100 write requests per second. Which pattern is most appropriate?
A) Event sourcing B) Microservices C) CQRS (Command Query Responsibility Segregation) with read replicas D) Serverless functions
Show Answer
**C) CQRS with read replicas.** CQRS separates the read model from the write model, allowing each to be optimized independently. Combined with read replicas, the read path can be scaled horizontally to handle the massive read load, while the write path remains simple. Event sourcing (A) addresses state management, not read scaling. Microservices (B) address team independence, not read/write asymmetry. Serverless (D) could help but does not specifically address the read/write imbalance.Question 24
When should ADRs be written?
A) Only during the initial system design phase B) Whenever a significant architectural decision is made, throughout the project's lifetime C) Only when the architecture team requests them D) Only when a decision is reversed
Show Answer
**B) Whenever a significant architectural decision is made, throughout the project's lifetime.** ADRs are living documents that capture the evolving architecture. They should be written at the time a decision is made (when the context and reasoning are fresh), not just at the beginning of a project. When a decision is superseded, a new ADR is written that references and replaces the old one.Question 25
How do ADRs improve AI-assisted development?
A) They automatically generate code from architecture specifications B) They provide context that helps AI assistants generate code consistent with architectural decisions C) They replace the need for code reviews D) They allow AI to make architectural decisions autonomously