5 ms·
I'm going to shamelessly take advantage of your being here with a question if that's ok. Do you have any recommendations for reading material that covers Phoeni
by jon-wood 6y ago
I'm going to shamelessly take advantage of your being here with a question if that's ok. Do you have any recommendations for reading material that covers Phoenix as it's used today?
Back in the early 0.x days I read the Phoenix book, which was a great introduction to building an application and using Ecto, but trying to pick it up again recently I found that nothing really seems to cover using Contexts in the real world.
- bennyp101 6y agoNot Jose (obviously), but I have a copy of https://pragprog.com/titles/phoenix14/programming-phoenix-1-4/ https://pragprog.com/titles/phoenix14/programming-phoenix-1-... which I think is still fairly relevant. Of course, there is always https://elixirforum.com https://elixirforum.com and a good search :)
- mwcampbell 6y agoThe book Programming Ecto [1] also has a chapter on application design which talks about contexts. [1]: https://pragprog.com/titles/wmecto/programming-ecto/ https://pragprog.com/titles/wmecto/programming-ecto/
- freedomben 6y agoI have that book too and it's great. Will have to check out that specific section. I mostly used it to see examples and explanations of how to do things in the Ecto DSL (which it is great for).
- strzibny 6y agoYes, I read and can recommend that book as well. I wanted to get the little OTP guide too, but people say it's outdated. Apart from books and forum though, there are many posts online! You can check ElixirStatus[0] or a new initiative called Beam Bloggers Webring[1]. [0] https://elixirstatus.com/ https://elixirstatus.com/ [0] https://beambloggers.com/ https://beambloggers.com/
- josevalim 6y agoThis may be a non-answer answer, but given you are versed on the Phoenix front, may I suggest a book on the design aspect of things? For example, Domain Driven Design Quickly: https://www.infoq.com/minibooks/domain-driven-design-quickly/ https://www.infoq.com/minibooks/domain-driven-design-quickly... It has been a while since I have read it, so it may be dated, but hopefully others can provide suggestions too!
- jon-wood 6y agoThanks :) I started reading the original DDD several years ago, but bailed out due to quite how dense it is, hopefully this summary will be a little more approachable.
- 1_player 6y agoYou probably have seen it already, but recent Phoenix docs have a section on contexts and what is their intended use case: https://hexdocs.pm/phoenix/contexts.html https://hexdocs.pm/phoenix/contexts.html The way I see it, context are just the public API to access your data model. Your Ecto schema is a piece of data, which in a functional language has no behaviour attached. The (business) logic to deal with this piece of data lives in the context. That's it. It's nothing particular and specific about Ecto or Phoenix, it's just a good design practice that's applicable and recommended in any language. Gary Bernhardt at https://www.destroyallsoftware.com https://www.destroyallsoftware.com has a few screencasts and talks about this very topic.
- freedomben 6y agoThanks, I'm not GP but have the same questions. What about access control? That's often directly tied into business logic, but it's so elegant and convenient to do it in the controllers or even the router using the pipelines. In fact a ton of the examples (I think even the Chris McCord Phoenix book) does exactly this, presumably for that reason. However I did that with an app and haven't been very happy with it because while the bulk can easily be done in the router/controllers, there are things that are totally inappropriate to do there and so it ends up in the context. Then your logic is distributed and messy, which is awful. But putting all access control in the context also bloats and complicates a ton of otherwise very clean, elegant API functions. I try to keep the Repo query building code clean and separate but that often leads to inefficiencies (such as filtering fields in the caller instead of in the generated SQL, which is vastly preferred for obvious reasons). Anyway, interested in thoughts on that.
- andy_ppp 6y agoThere’s already an article on this you can find here: https://dashbit.co/blog/a-new-authentication-solution-for-phoenix https://dashbit.co/blog/a-new-authentication-solution-for-ph... The GitHub for the generator is here: https://github.com/aaronrenner/phx_gen_auth https://github.com/aaronrenner/phx_gen_auth Basically if you need something different it might be worth forking the generator. I might look at passwordless login at some point.
- Storm-Bringer 6y agoHave a look at this - https://pragmaticstudio.com https://pragmaticstudio.com They have courses on Elixir, Phoenix and today have just released a LiveView course.
- acoustep 6y agoJust to add to your comment: I've been running through the free LiveView course and it's been really great. I'm excited to finish it and continue with the pro one!
- abrookewood 6y agoJust adding that I found those courses really helpful as well.
- deleted 6y ago[deleted]
- sodapopcan 6y agoContexts are loosely (maybe a little more than loosely) based on the Bounded Context concept in Domain Driven Design. As a good introduction, I would recommend reading Domain-Driven Design Distilled by Vaughn Vernon. It's sort of like the Cole's Notes version of the full Domain Driven Design which is a monster of a book.