DDD/CQRS/EVENTS Flashcards

1
Q

What is DDD?

A

It’s a way of designing and implementing software that aims to reduce complexity by focusing on the business domain and connecting the implementation to the domain, resulting in expressive and flexible solutions.

The canonical text is Eric Evans’ Domain Driven Design.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the fundamental part of DDD?

A

Doing DDD does not require any particular framework, language, architecture etc. In particular, you can do DDD without CQRS, event sourcing, etc.

The fundamental part of DDD is the focus on the domain, which translates into the UBIQUITOUS LANGUAGE - the core terms and expressions of the domain that should be reflected in the software itself. The process of discovering the ubiquitous language itself results in a better understanding of the domain.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How does DDD differ from the Clean Architecture?

A

DDD is not tied to any particular architecture. The core architectural part of DDD is a rich domain model, meaning entities (classes) that are rich in behaviour and closely reflect the real word business problem.

The main focus of clean architecture is having a core layer which should not depend on any external framework, service etc. In clean architecture, dependencies should point inwards. And this is true also of typical DDD architectures, where the rich domain model is at the core of the architecture and should not have any dependencies on infrastructure concerns etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

In DDD what is the domain model

A

The domain model is the set of entities and value objects that make up the domain and are at the core of the architecture. The entities should not just be data, but should be rich in behaviour. They should encapsulate the business logic. True OOP.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

In DDD what are domain services

A

Domain services are part of the domain model and are responsible for any behaviour that does not fit into a single entity (aggregate) (e.g. behaviour that must span more than one entity).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

In DDD what are application services

A

Application services interact directly with the domain model, and the rest of the application interacts with the application services. The app services are responsible for coordinating the behaviour of the domain model entities and domain services. The app services are the clients of the domain model.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

In DDD what are persistence and infrastructure layers?

A

The layers responsible for persistence and infrastructure e.g. web, caching, external services etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

In DDD what is an aggregate?

A

A DDD aggregate is a cluster of domain objects that can be treated as a single unit. It is the logical boundary for things that can change in the business transaction of a given context.
It can be made up of one or several entities. In case of several, then one of them is the aggregate root, which interacts with the outside world and contains the others.
Aggregates should be saved as one and retrieved as one.
The root ensures the integrity of the whole aggregate.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

In DDD what is an Entity vs a Value Object

A

Entities have distinct identities. Two entities that have the same properties are still distinct things.
A value object (think a Money class) does not have a distinct identity. If 2 Money types have the same property (e.g. amount and currency), they are considered equivalent. Value objects should be immutable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is CQRS?

A

Command Query Responsibility Segregation. Essentially splitting up your architecture into a command side and a query side. Commands change data. Queries never change data, only retrieve it.
By splitting them up, you can have have different data access patterns - e.g. the query side can use straight SQL while the command side uses an ORM.
This can also simplify your domain model as it can be used only for the command side (the query side does not really need a rich domain model as it is basically just querying data from the DB).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Describe more or less how CQRS/”command pattern” works

AKA this kind of thing https://blogs.cuttingedge.it/steven/posts/2011/meanwhile-on-the-command-side-of-my-architecture/

A

Each feature is either a command or a query. A command or a query are objects that encapsulate the data that makes up the command or query.
Controllers will accept data and translate this into a command or query. This will be passed to a command handler which handles the command or query, calling upon domain model entities or services to do the work.
This is great for decoupling your application. Every feature is implemented in a single command or query and respective handler and there is very little coupling between functionality. Reuse of code can be done but prudently; duplication is OK if it means that things remain decoupled. The main thing here is SRP - single responsibility principle.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is event sourcing?

A

With event sourcing every action taken within a system is an event that is stored in an event store. So instead of storing the current state of data, you store each event. To get to the current state you basically replay the events from the store.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

In DDD what is bounded context?

A

todo

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the specification pattern?

A

Encapsulating domain rules in classes that can be reused. E.g. they encapsulate an expression like:
thing => thing.age >= 18

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How do you avoid CRUD based thinking?

A

More logic and behaviour in models. Encapsulation is key.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly