ssbb
How to determine contexts with Phoenix 1.3
I am just trying to migrate my project to Phoenix 1.3 with new contexts mechanism. But I am not sure how I should split my schemas into this contexts. I read a lot about DDD and UL/Bounded Contexts in last few days, but all examples using something like large ERP systems. Also in DDD contexts used to “namespace” UL (ubiquitous language) within this contexts like Sales/Support/Analytics, etc. where Product will be used.
At other side @chrismccord used blog (post, comments) example in his ElixirConf talk. So it looks more like module organization (maybe like Django re-usable apps) and not business model separation to scope UL within this context. So how to know when bounded context should be used?
Whats if I have pretty simple project where I have no overlaps in UL? How to scale DDD down in this case? Maybe just use single context?
Should I think about contexts as module organization - Blog, Accounts, etc. or it is really DDD contexts like Sales/Support? I am confused when they are used together (at single ElixirConf talk by @chrismccord).
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #performance










First 10 of 76 Posts
ssbb
Just found @anders answer:
but I still can’t get used with this Blog example. For me it looks like some re-usable code (maybe umbrella later) and not real Bounded Context in terms of DDD
LostKobrakai
I know this might not help you much, but just try to work on your app instead of trying to hard to fit your context structure in some kind of predefined schema. In the end it’s your app; you decide what’s worth splitting up and what’s not. Also elixir makes it quite easy to move things around even at a later time.
For example in one application it might be best to leave those 2-3 functions related to registaration with the other user handling (auth, …), while in another one registering might be a quite complex task with multiple steps involved. In that case the registration is probably better moved in a own context separate from other user related tasks. When exactly it’s time to move things in different context is a decision you’ve to make on your own and as stated is mostly dependent on the very app you’re working on.
smithaitufe
Sincerely, since bounded context was introduced in version 1.3, it has been very difficult working on something. It has however exposed me to a new way of thinking. It will be better if @chrismccord and his team furnishes us with samples like they do in aspnet core. This will help us to have good understanding of this approach. I love phoenix but I couldn’t use the version 1.3 on a new project that I am working on because I was confused. I went for dotnet core even though my heart is in love with phoenix.
michalmuskala
One important thing - this is not bounded context. The primary aim is to encourage building modular code. If you use DDD and bounded contexts for this - it’s your choice. But it’s just modules & functions until you yourself decide it’s something more in your application.
smithaitufe
@michalmuskala This is quite interesting. I voted for no context as proposed by Jose. However as a work around, I am thinking of using the project name as my default context as we would do in entity framework, eg LibrilleDbContext. This will hold all the tables that will be created. If need be for new context, I could then restructure it. However, this does not eliminate the need for samples. This will help ELIXIR and PHOENIX adoption.
I wish I am really good like you in Elixir. You are always there to talk to me whether at slack or here. Thanks
StanBright
It’s the same with me. It feels more difficult working with Phx 1.3 compared to 1.2. However, I believe that’s because I’m too used to the Rails way…
LostKobrakai
It’s really interesting how different experiences can be. I’m not coming from rails, but the php world and I’ve had the best time rewriting a website in phoenix 1.3. First I played a bit with the context generators, but I found them to generate to much stuff (whole crud for each struct/schema), so I moved to creating my own contexts. It’s now super obvious where stuff is done as each context handles a single concern of the website. The whole web layer is only there to trigger stuff deeper in the application and to translate the returned values into markup / flash messages / …. I can use the whole app via iex without ever touching a single conn struct, nor any Repo.something() calls. Sure there was some time needed to get worm with that new approach, but I didn’t find that more difficult than trying to use phoenix 1.2 for the first time.
smithaitufe
@LostKobrakai it’s good to know you find it very intuitive to work with. If you mind, can you share what you have? Perhaps the github repository if it is not private.
LostKobrakai
I can’t share the code, but it’s a website where people can register for a local event and I used the following contexts: auth, email, faq, newsletter, pdf, registration, ticketing and support. These where simply the things needed for the website and which felt to be distinct enough pieces of the whole. That’s why I think nobody can really tell anyone else what contexts they should use.
ssbb
Thank you, thats what confused me. So contexts in terms of Phoenix means just module scoping and not real DDD? Just for @chrismccord answer at forums it looks like real DDD bounded contexts:
And when examples for different usages (module organization, DDD contexts to scope UL) appears here - I get confused