Originally introduced and made popular by Eric Evans in his book Domain-Driven Design: Tackling Complexity in the Heart of Software, Domain-Driven Design or DDD simply refers to building software centered around its “domain” - the subject area of its application in the real-world. It relies heavily on “domain contexts” - establishing clear boundaries between pieces of business logic as well as “domain models” - defining binding contracts for a domain. In my experience designing applications, incorporating DDD helps achieve the following wins in a software development lifecycle: Easy collaboration (with other developers), faster iteration cycles, better management of complexity, and “Clean code” - readable, reusable, maintainable.
In the realm of Elixir, this can all be achieved by using Models and Contexts in your application. In this presentation, I’ll take on an example domain design, and walk through in-detail on implementing domain Models using Ecto and Changesets, housing business logic in Contexts, and how they both fit with each other. I will briefly touch on some other features like Behaviors and Macros that may aid DDD. I also plan on sharing some tips/tricks for knowing when it is time to split code amongst contexts and the way related contexts come together. I will share my learnings encountered while adopting this approach, and go over some potential pitfalls.
All in all this talk will be a quick primer to building well-rounded domain centric apps using some of Elixir’s best features. I believe this presentation would help beginners seeking direction before designing/programming their apps, and also to those looking to refactor their apps to be more maintainable and scalable.