DDD Flashcards

1
Q

What is DDD? And what are the main advantages?

A

DDD - is Domain-Driven Design

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

What is Bounded Context?

A

Bounded context is a logical boundary.

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

What is domain?

A

Domain is a representation of our reality in the code.

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

What is tactical pattern?

A

Focus on items that help you build the model or building block of domain model. ( Entity, DesingPattern )

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

What is value object?

A

It’s just a class which responsible for some behavior ( for example Time) Think of them as adjectives in your domain. Value Objects have No identity. Something simular to pure function.

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

What is Entity?

A

Domain obejct with unique identity ( Value object with id Model in ActiveRecord ). Usually has mutable state ( you can change name for examlple)

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

What is aggregate?

A

It’s a set of composed domain object defining single consistency unit. One aggregate -> One transaction.

Aggregate has one EntryPoint - Root ( Only using this root outer objects can get access to it)

Entities can be grouped into aggregates. For instance, order is an entity, but it can also be an aggregate, which includes two entities: order and order item ( record and its associations )

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

What is domain event?

A
  • It’s a way to communicate between bounded context

- An object that is used to record a event related to model activity within the system.

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

What is CQS?

A

Command–Query Separation (CQS).

Every method should either be a command that performs an action, or a query that returns data to the caller, but not both.

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

How to split rails models into bounded context?

A

We can use modules.

admin/product
user/product
sale/product

class Admin::Product < ApplicationRecord
end
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What can helps us to split big model into the smallest one?

A
  • fields_name ( first_address, second_address)
  • prefix/postfix
  • some fields updates in one transaction always
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Can you provide examples of value objects?

A
  • Time
  • Money
  • Date
  • Point
  • Location
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Can you provide examples of Entities?

A
  • User
  • Customer
  • Account
  • Banknote ( with serial number)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Can you provide examples of Aggregates?

A
  • Unit

- CreateCar ( many action, authrizers, policies, forms inside)

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

What the service mean in DDD?

A

This is a logic which gather some agregates together to perform some action ( Unit as example in our project )

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

What the command object mean in DDD?

A

Commands are structures that contain all the attributes necessary to perform an operation in your
system and describe the intention. ( Something like a form with Virtus on our project)

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

What is Repositories in DDD?

A

The DDD meaning of a repository is a service that uses a global interface to provide access to all entities and value objects that are within a particular aggregate collection. ( Something simular to query? )

18
Q

What is Command Bus in DDD?

A

The command bus matches commands to handlers.

SubmitOrderCommand => method(:submit),
ExpireOrderCommand => method(:expire),
CancelOrderCommand => method(:cancel),
ShipOrderCommand => method(:ship),

I see only one advatadges right now. This allow to set a strict border between clasess/units. You can set restriction to run only action from command bus for example and in this case you won’t be able to run any other action ( outside of this context for example)

Command bus as routing layer but on application level

19
Q

What rules you should use to select a correct name for domain events?

A
  • Something that alredy happened
  • Should be named in past tense…
  • Represents a state change,
  • Try to use names with business value ( not only CRUD )
20
Q

What can we do with Domain Events?

A
  • persist in database / event store

- publish it for subscribers using a pub/sub mechanism

21
Q

What is Event Handler?

A

This is a logic that receives events and rect to them somehow.

22
Q

What is the diffirence betweeen Sync and Async events handlers?

A
  • Sync events handlers ( Run event_handler/Subscriber directly after sending event)
  • Async event handlers save events to the MessageQueue ( Sidekiq, DelayJob)
23
Q

Can you give me example of breaking CQS?

A

when method implement action and actially reaturn changed value

p. next # 1
p. next # 2

The example above don’t break this principle

p. next # nil; # command
p. current # 1 # query
p. next # nil
p. current # 2

24
Q

What is CQRS?

A

The Command Query Responsibility Segregation (CQRS) pattern separates read and create/update/delete operations for a data store. The main advantage is reading perfomance improvement.

We can compare it with CRUD. Query it’s READ in CRUD. Command is CREATE, UPDATE, DELETE, or any other operation.

25
Q

What is a process manager?

A

This is something that can help you orgnaize communication between context. Something simular to state machine ( For example -> Buy ticket -> Pay money -> Gerate PDF)

26
Q

What 4 main layer has layer architecture?

A
  • User Interface ( Presentation layer ) Show info to user
  • Application layer - Select which model/domain we should use
  • Domain/ Model layer - main layer ( logic/state)
  • Infrastructure layer - technically hepls implement domain layer
27
Q

What is Smart UI?

A

When you don’t have any layers and all business logic is present inside User Interface.

28
Q

What is factory?

A

A program element that is RESPONSIBLE for creating objects is called a FACTORY.

29
Q

What is specification (by restriction)?

A

It’s the same as validator. Just strictly show the object limit.

30
Q

What is specification (select by request)?

A

Provides you data for you model object. Can use combination of aggregates/queries. In most cases soemthing very specific.

31
Q

What is specification by ( generate by request )

A

It’s a generator which takes params and add additionla logic to this param. When you create something -> you automaticly creates some environment around this somehow.

32
Q

What is side effect free function?

A

Функции без побочных эффектов. This is a function which don’t produce enxpected behavior ( just calculate and return something without changing argument). Separate function into 2 group ( which one is modified something and just return a value )
[].map

33
Q

What is assertetion?

A

Методы, изменяющие состояние системы, можно характеризовать с помощью УТВЕРЖДЕНИЙ.

It’s something that can update argument during the calculation.
[].map! ( Or something related to spec strict rules )

34
Q

What is CLOSURE OF OPERATIONS?

A

Замкнутость операций. When type of returned value is always equal to type of arguments. ( 1 + 1 = 2 always)

35
Q

What is shared kernel?

A

This is a common area between 2 contexts.

36
Q

What is context map?

A

All contexts in your project and their itteraction with each other.

37
Q

What is CUSTOMER/SUPPLIER approach?

A

It’s a relation when somthing from high level depends on something from low level.

38
Q

What is Distillation?

A

Distillation is the process of identifying the domain, decoupling it, isolating it, clarifying it and making it explicit, allowing us to focus on what is more relevant and having it maintainable.

39
Q

What is core domain?

A

It’s the most import part of application.

40
Q

What is core domain?

A

It’s the most import part of application. Without this part your app can’t exist at all.

41
Q

What is generic subdomain?

A

This is a part of application which just add some additional logic to the main core domain.( i18n, parsing)