Slide 1

Slide 1 text

Никита Соболев github.com/sobolevn

Slide 2

Slide 2 text

Вы неправильно поняли DDD

Slide 3

Slide 3 text

Domain Driven Design

Slide 4

Slide 4 text

Focus on the core domain; explore models in a creative collaboration of domain practitioners and software practitioners; and speak a ubiquitous language within an explicitly bounded context — Eric Evans youtube.com/watch?v=R2IAgnpkBck

Slide 5

Slide 5 text

– Сергей, сделай мне отчет по транзакциям

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

Как такая проблема вообще возникла?

Slide 8

Slide 8 text

1968 • Программистов нет • Код пишут специалисты из предметной области • Каждый отвечает за свой участок youtube.com/watch?v=XH_awPS6hK4

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

Slide 11

Slide 11 text

Инструмент технического общения Тайный!

Slide 12

Slide 12 text

Through domain models, software developers are able to express rich functionality and translate it into a software implementation that truly serves the needs of its users — Eric Evans

Slide 13

Slide 13 text

defmodule Projects.Entities.Project do schema "projects" do field :url, :string many_to_many :participants, User, join_through: UserProject, on_replace: :delete end end Project

Slide 14

Slide 14 text

- Let project's participants copy URL

Slide 15

Slide 15 text

- Let project's participants copy URL field :url, :string

Slide 16

Slide 16 text

- Let project's participants copy URL field :url, :string many_to_many :participants, User

Slide 17

Slide 17 text

- Let project's participants copy URL Projects.Entities.Project field :url, :string many_to_many :participants, User

Slide 18

Slide 18 text

defmodule Kira.Usecases.AssignUserToTask do @moduledoc """ We need to assign free `User`s to the most important tasks. We mean `Issue` and `Merge Request` by tasks. Different tasks have different priorities. """ operation(Kira.Projects.Services.FindTaskToAssign) operation(Kira.Accounts.Queries.FindFreeDeveloper) operation(Kira.Accounts.Commands.AssignDeveloper) end Появляются сложные концепции

Slide 19

Slide 19 text

defmodule Kira.Usecases.AssignUserToTask do @moduledoc """ We need to assign free `User`s to the most important tasks. We mean `Issue` and `Merge Request` by tasks. Different tasks have different priorities. """ operation(Kira.Projects.Services.FindTaskToAssign) operation(Kira.Accounts.Queries.FindFreeDeveloper) operation(Kira.Accounts.Commands.AssignDeveloper) end Варианты использования

Slide 20

Slide 20 text

defmodule Kira.Usecases.AssignUserToTask do @moduledoc """ We need to assign free `User`s to the most important tasks. We mean `Issue` and `Merge Request` by tasks. Different tasks have different priorities. """ operation(Kira.Projects.Services.FindTaskToAssign) operation(Kira.Accounts.Queries.FindFreeDeveloper) operation(Kira.Accounts.Commands.AssignDeveloper) end Контексты

Slide 21

Slide 21 text

defmodule Kira.Usecases.AssignUserToTask do @moduledoc """ We need to assign free `User`s to the most important tasks. We mean `Issue` and `Merge Request` by tasks. Different tasks have different priorities. """ operation(Kira.Projects.Services.FindTaskToAssign) operation(Kira.Accounts.Queries.FindFreeDeveloper) operation(Kira.Accounts.Commands.AssignDeveloper) end Сервисы

Slide 22

Slide 22 text

defmodule Kira.Usecases.AssignUserToTask do @moduledoc """ We need to assign free `User`s to the most important tasks. We mean `Issue` and `Merge Request` by tasks. Different tasks have different priorities. """ operation(Kira.Projects.Services.FindTaskToAssign) operation(Kira.Accounts.Queries.FindFreeDeveloper) operation(Kira.Accounts.Commands.AssignDeveloper) end Запросы

Slide 23

Slide 23 text

defmodule Kira.Usecases.AssignUserToTask do @moduledoc """ We need to assign free `User`s to the most important tasks. We mean `Issue` and `Merge Request` by tasks. Different tasks have different priorities. """ operation(Kira.Projects.Services.FindTaskToAssign) operation(Kira.Accounts.Queries.FindFreeDeveloper) operation(Kira.Accounts.Commands.AssignDeveloper) end Команды

Slide 24

Slide 24 text

Usecase Command Query CQRS Event Sourcing Entity Domain Model Value Object Service Agregate Root Bounded Context Context Agregate

Slide 25

Slide 25 text

Usecase Command Query CQRS Event Sourcing Entity Domain Model Value Object Service Agregate Root Bounded Context Context Agregate

Slide 26

Slide 26 text

Usecase Command Query CQRS Event Sourcing Entity Domain Model Value Object Service Agregate Root Bounded Context Context Agregate

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

github.com/johnnncodes/ ddd-python-django

Slide 30

Slide 30 text

class Ticket(object): __uuid = None def __init__(self, uuid, title, body, customer_id): self.set_uuid(uuid) self.set_title(title) self.set_body(body) self.set_customer_id(customer_id) def set_title(self, title): self.__title = title def get_title(self): return self.__title def set_body(self, body): self.__body = body

Slide 31

Slide 31 text

github.com/commanded/ commanded

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

Как так получилось?

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

Как все те умные слова относятся к вашей предметной области?

Slide 38

Slide 38 text

Никак!

Slide 39

Slide 39 text

Инструмент технического общения

Slide 40

Slide 40 text

Архитектурные паттерны Предметная область

Slide 41

Slide 41 text

Архитектурные паттерны Предметная область

Slide 42

Slide 42 text

Например, микросервисы youtube.com/watch? v=yPvef9R3k-M

Slide 43

Slide 43 text

"DDD Framework"

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

Что важно? •Быстрая обратная связь •Общая терминология •Понятные требования

Slide 46

Slide 46 text

– Никита, мне нужен инструмент для автоматизации работы программистов

Slide 47

Slide 47 text

Термины и связи

Slide 48

Slide 48 text

sphinx-doc.org

Slide 49

Slide 49 text

class AwesomeRule(object): """Implementation of :term:`rule` ..."""

Slide 50

Slide 50 text

Сделал – получил обратную связь!

Slide 51

Slide 51 text

Показал – обновил

Slide 52

Slide 52 text

BDD

Slide 53

Slide 53 text

Еще один неправильно понятный инструмент для общения

Slide 54

Slide 54 text

Feature: Tracking issues progress As an architect I want to have information about Gitlab issues So that I can overview and track the issues' progress Scenario: new valid issue webhook is received Given issue webhook is valid And issue webhook is authenticated When it is received Then a new issue is created Scenario: new invalid issue webhook is received Given issue webhook is not valid When it is received Then no issue is created

Slide 55

Slide 55 text

No content

Slide 56

Slide 56 text

pypi.org/project/pytest-bdd

Slide 57

Slide 57 text

sobolevn.me/2019/02/ engineering-guide-to- user-stories

Slide 58

Slide 58 text

Мы понимаем что делать

Slide 59

Slide 59 text

Заказчик понимаем, что мы делаем

Slide 60

Slide 60 text

Сделал – получил обратную связь!

Slide 61

Slide 61 text

No content

Slide 62

Slide 62 text

Мы можем быть уверены: работает, то, так

Slide 63

Slide 63 text

Выводы •DDD позволяет людям понять друг друга •DDD поднимает сознательность, заставляет думать про бизнес •DDD позволяет быстрее решать задачи •DDD заставляет думать про архитектуру

Slide 64

Slide 64 text

Материалы •DDD EU •twitter.com/DDD_Borat •fsharpforfunandprofit.com/ddd/ •fideloper.com/hexagonal-architecture •martinfowler.com/eaaCatalog/index.html •github.com/heynickc/awesome-ddd •github.com/dry-python

Slide 65

Slide 65 text

Вопросы? github.com/sobolevn sobolevn.me