samrose
Looking for opinions.
I am in discussion with someone who would like to restructure phoenix project file structure so that model, view, controller, and tests will be all in one folder per named “feature” (let’s say “blog”)
I am looking for feedback on what the tradeoffs would be for doing this.
The argument for it is that “everything you need to find for the feature would be in one folder. This should be easier for everyone to find and use these files”. But are there fundamental reasons not to restructure a phoenix project in this way? I know it would lose compatibility with with code generators. However, would this also push people off track in their reasoning about he code? What are the impacts if any, for doing this?
Thanks!
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Kia ora,
We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
Hello,
I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter).
The diffic...
New
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
Other Trending Topics
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
Latest Phoenix Threads
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
- #blog-post
- #ai
- #phoenix_html
- #iex
- #elixirconf-us
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
BartOtten
Have a look in this topic: Discussion about domain-orientated folder structures in Phoenix
dimitarvp
Has this person considered code that must be reused between two or more features? Then their idea kind of falls apart.
benwilson512
Controller / view code isn’t really this way though. I definitely agree with you that
"model"code definitely doesn’t belong to a specific controller. However for controller / view stuff there’s a decent argument for favoring a “pod” structure.While not exactly the same, LiveView definitely takes more of a “page” oriented structure since with a given live view + leex / heex template you generally have a bunch of functionality all right next to each other.
dimitarvp
I don’t disagree but let’s take this to the extreme: should each feature have a copy of the root layout code then?
The stance described in OP seems too extremist and narrow-minded to me. Partially applied it is valuable but I’ve rarely seen people advocate for such things in an moderate manner. It’s usually an all-or-nothing affair. Maybe it was a bad luck on my part, I don’t know.
samrose
Thank you!
samrose
The way being proposed is indeed all the model, view, controller as described FWIW
BartOtten
In practice, it’s never about the extremes though. As there is a ‘data’ App and a separate ‘web’ AppWeb both styles can be used together.
If we look at how the phx generator creates the data app, we see vertical slicing as far as I can remember. Except for migrations which are all in one folder*. It’s the web app that (historically) uses horizontal slicing and although it can be beneficial, I rather use vertical slicing there too.
LiveView seems to move towards vertical slicing, with the template files next to the rest of the code for a page/view.
*Django puts migrations within the ‘feature’. Con: touch two features at once and you have two separated migration files.
BartOtten
I would not favor an all-in-one approach with models next to views, as having both an data app and web app makes a good boundary. So there I draw a line: The data app is meant for handling data requests, the web app for handling web requests. Easy distinction
.
It also allows me to have a clear seperation between types of ‘frontend’. For example:
data/
web_api/ (using jwt tokens)
web_live/ (using sessions)
Sasa Juric (iphone won’t let me spell it correctly) has a good blog serie about the way the company he works for separates code(files). Highly recommend to read them.
BartOtten
Although being designed for React, you can find value information about vertical slicing in there.
stefanchrobot
I use that approach in my app and I’m pretty happy with it! I don’t use generators though. I even have two separate “
myapp_web.ex” files - one for the SSR app and one for the API: