Upgrade to Pro — share decks privately, control downloads, hide ads and more …

You got DDD wrong

You got DDD wrong

Sobolev Nikita

March 22, 2019
Tweet

More Decks by Sobolev Nikita

Other Decks in Programming

Transcript

  1. 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
  2. 1968 • Программистов нет • Код пишут специалисты из предметной

    области • Каждый отвечает за свой участок youtube.com/watch?v=XH_awPS6hK4
  3. 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
  4. 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
  5. 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 Появляются сложные концепции
  6. 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 Варианты использования
  7. 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 Контексты
  8. 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 Сервисы
  9. 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 Запросы
  10. 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 Команды
  11. Usecase Command Query CQRS Event Sourcing Entity Domain Model Value

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

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

    Object Service Agregate Root Bounded Context Context Agregate
  14. 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
  15. BDD

  16. 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
  17. Выводы •DDD позволяет людям понять друг друга •DDD поднимает сознательность,

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