CPP Design Patterns & Software Architecture 2 β Questions and Answers
Question 1: What is microservices architecture?
- Building a single application as one tightly coupled deployable unit
- Structuring an application as a collection of small, independently deployable services each responsible for a specific business capability (Correct answer)
- Using very small functions with no shared state
- A pattern for minimizing memory usage in embedded systems
Correct answer: Structuring an application as a collection of small, independently deployable services each responsible for a specific business capability
Microservices decompose an application into loosely coupled services that can be developed, deployed, and scaled independently.
Question 2: What is the Repository pattern?
- A version control strategy for code
- An abstraction layer over data access logic that provides a collection-like interface for accessing domain objects (Correct answer)
- A pattern for caching database queries
- A pattern for organizing microservice APIs
Correct answer: An abstraction layer over data access logic that provides a collection-like interface for accessing domain objects
The Repository pattern decouples business logic from data access concerns, making it easier to swap data sources and write unit tests.
Question 3: What is Domain-Driven Design (DDD)?
- Designing databases first, then building the application around them
- An approach that centers software design around a rich model of the business domain, using a shared ubiquitous language (Correct answer)
- Designing UI components that mirror business workflows
- A methodology for prioritizing features in a product backlog
Correct answer: An approach that centers software design around a rich model of the business domain, using a shared ubiquitous language
DDD aligns software structure with business concepts using bounded contexts, aggregates, and a shared vocabulary between developers and domain experts.
Question 4: What is CQRS (Command Query Responsibility Segregation)?
- Separating SELECT and INSERT SQL statements into different files
- A pattern that separates read (query) and write (command) operations into distinct models (Correct answer)
- Using different databases for development and production
- A caching strategy using separate read replicas
Correct answer: A pattern that separates read (query) and write (command) operations into distinct models
CQRS uses separate models for updating and reading data, enabling independent optimization, scaling, and even different storage for each side.
Question 5: What is the Adapter design pattern?
- Adapting business requirements into technical specifications
- A pattern that converts the interface of a class into another interface expected by the client (Correct answer)
- Modifying an existing class to add new methods
- A pattern that wraps a group of related operations
Correct answer: A pattern that converts the interface of a class into another interface expected by the client
The Adapter pattern acts as a bridge between incompatible interfaces, allowing classes to work together that otherwise could not.
Question 6: What is event-driven architecture?
- Architecture triggered by user mouse clicks only
- A design where components communicate by producing and consuming events asynchronously via an event bus or message broker (Correct answer)
- A pattern for scheduling timed background jobs
- An architecture where events are logged to a database
Correct answer: A design where components communicate by producing and consuming events asynchronously via an event bus or message broker
Event-driven architecture decouples producers from consumers so services react to events without direct dependencies on each other.
What is microservices architecture?