DDD Flashcards
What is DDD? And what are the main advantages?
DDD - is Domain-Driven Design
What is Bounded Context?
Bounded context is a logical boundary.
What is domain?
Domain is a representation of our reality in the code.
What is tactical pattern?
Focus on items that help you build the model or building block of domain model. ( Entity, DesingPattern )
What is value object?
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.
What is Entity?
Domain obejct with unique identity ( Value object with id Model in ActiveRecord ). Usually has mutable state ( you can change name for examlple)
What is aggregate?
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 )
What is domain event?
- 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.
What is CQS?
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 to split rails models into bounded context?
We can use modules.
admin/product
user/product
sale/product
class Admin::Product < ApplicationRecord end
What can helps us to split big model into the smallest one?
- fields_name ( first_address, second_address)
- prefix/postfix
- some fields updates in one transaction always
Can you provide examples of value objects?
- Time
- Money
- Date
- Point
- Location
Can you provide examples of Entities?
- User
- Customer
- Account
- Banknote ( with serial number)
Can you provide examples of Aggregates?
- Unit
- CreateCar ( many action, authrizers, policies, forms inside)
What the service mean in DDD?
This is a logic which gather some agregates together to perform some action ( Unit as example in our project )
What the command object mean in DDD?
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)