elt547
Anyone have tips for code organization?
I’m new to elixir, and I’m finding that I often have files have many responsibilities, which I’m not fond of. One frequent occurrence of this I’m seeing is the context files in a phoenix project. If you have many different schemas under that context, you end up having a ton of boilerplate like create_user, create_account, create_admin right next to each other. I really don’t like this and I could see this growing out of control very quickly in a project of consequence. I can’t open up modules for modification in more than one file, as things are overwritten. I’m at a loss at how to deal with this and in my opinion it’s a big downside of using elixir/phoenix and the default code generators in phoenix.
Does anyone have any tips or resources on using files to separate code in elixir?
Most Liked
beepbeepbopbop
I would also recommend reading a multi part series as well that Sasa wrote: https://medium.com/very-big-things/towards-maintainable-elixir-the-core-and-the-interface-c267f0da43
That’s one part of the 4 I think, of which every single one has incredible value to be pulled from. Like anything, don’t be too dogmatic about it, it’s very likely you won’t nail it the first couple of times, but as long as you have these concepts in the back of your head, certain patterns tend to emerge.
Hermanverschooten
I like. what Sasa does in his talks, eg https://www.youtube.com/watch?v=6sNmJtoKDCo
eahanson
One trick is to generate a new Phoenix app in some scratch directory, use Phoenix schema etc. generators there, read the generated code, and then implement something similar by hand in your real app, putting everything where you want it.
Popular in Questions
Other popular 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
- #javascript
- #code-sync
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








