German Velasco - Using DDD concepts to create better Phoenix Contexts
Leave comments at: https://elixirforum.com/t/elixirconf-2023-german-velasco-using-ddd-concepts-to-create-better-phoenix-contexts/59139 Phoenix contexts were introduced in Phoenix 1.3. Four minor versions later, we’re still confused when trying to apply them in our applications. Contexts may make sense in theory, but it is hard to figure out just what makes a good context when it comes to practice. At least I know I’ve created many “contexts” that became… glorified junk drawers. That’s because Phoenix contexts are generic: they’re a namespace. So, even though they give us a nudge in the right direction, they don’t provide enough guidance to implement our own successfully. That’s where domain-driven design (DDD) can help us. Using DDD’s concepts, we can create different Phoenix contexts based on their role! So, join me as we walk through different types of Phoenix contexts we can use in our applications. Some will be DDD’s bounded contexts (different from Phoenix contexts), others will be DDD entities, and others will be DDD aggregates. By the end, you’ll have a more extensive toolset for creating Phoenix contexts and a new lens through which you can organize your Elixir modules.