ElixirConf 2023 - German Velasco - Using DDD concepts to create better Phoenix Contexts

Using Domain-Driven Design (DDD) concepts to improve Phoenix Contexts, German Velasco shares insights on bounded contexts, aggregates, value objects, and more to simplify your Elixir programming journey.

Key takeaways
  • DDD (Domain-Driven Design) encourages separating problem space into subdomains and bounded contexts to improve modeling and understanding.
  • Bounded contexts are autonomous and separate, but may interact through events and commands.
  • Events are data structures that trigger actions, while commands execute actions.
  • Aggregates are clusters of associated entities that transform data and maintain business invariants.
  • Value objects are immutable data structures that define an identity of their own.
  • Queries and commands should be decoupled to allow for different query patterns and command pipelines.
  • Phoenix Contexts can be improved by applying DDD concepts, such as bounded contexts, aggregates, and value objects.
  • Using functional programming techniques, like function composition, can simplify code and improve maintainability.
  • Context changes the meaning of words, so understanding the problem space and language is crucial.
  • Domain experts and stakeholders should be consulted to ensure accurate modeling of the problem space.
  • Code should be organized into separate domain-specific modules to maintain separation of concerns.
  • Phoenix Contexts can be composed of aggregate operations, like create, read, update, delete, to simplify interaction with the database.
  • Bootstrapping domains and bounded contexts can help to create a clear understanding of the problem space.