Domain-Driven Design Basics — Concept Check
Questions on Domain-Driven Design Basics. DDD aligns software structure with business domains; key building blocks include entities, value objects, aggregates, repositories, services, and domain events.
Questions in this quiz
8 questions on Domain-Driven Design Basics — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.An Order entity is in 'DRAFT' status. What happens if you try to add a line to it?
- AAn exception is thrown due to status restriction.
- BThe order status changes to 'PLACED'.
- CThe line is added successfully.
- DThe line is ignored without error.
2.You have a Money value object in your application. What happens if you try to modify its amount?
- AAn exception is thrown due to immutability.
- BThe operation is ignored.
- CThe amount changes successfully.
- DA new Money object is created with the new amount.
3.A developer suggests using Domain Services to handle persistence logic. Why is this incorrect?
- ADomain Services should be stateless and not handle persistence.
- BDomain Services are only for UI logic.
- CDomain Services cannot access the database.
- DPersistence logic belongs in Repositories.
4.An Order aggregate root has multiple OrderLine objects. How should these be accessed?
- AUsing a Domain Service.
- BVia a separate OrderLine repository.
- CDirectly from a database query.
- DThrough the Order aggregate root.
5.What is a potential issue if Domain Events are not published after persisting an aggregate?
- AEvents might be published with stale data.
- BEvents might cause data inconsistency.
- CEvents might not be published at all.
- DEvents might be published multiple times.
6.Why is it incorrect to compare two Entity objects by their attributes?
- AEntities must be compared by ID, not attributes.
- BComparing attributes is inefficient.
- CEntities are immutable, so comparison is invalid.
- DAttributes can change over time.
7.A developer claims that Aggregates can be mutated directly without going through the root. Why is this a flawed approach?
- AIt can lead to invariant violations.
- BIt is less efficient.
- CIt makes the code harder to maintain.
- DIt violates the principle of encapsulation.
8.What is the role of a Repository in DDD?
- ATo handle UI interactions with the domain model.
- BTo manage domain events and their lifecycle.
- CTo implement business logic across entities.
- DTo provide collection-like access to aggregate roots.