AstonJ

AstonJ

Vertical slicing architecture in Phoenix - anyone utilising it? Pros/cons?

Anyone doing vertical slicing in a Phoenix app? If I am understanding the term correctly this essentially means you can organise your app’s files by individual components - so a bit like Phoenix Contexts but going a step further by directory. For instance you could have a Registrations component and all the relevant files would be in the registrations directory, or you could have a Profiles component and all its files in there, etc.

I’m not sure why I am thinking it but seem to recall there may have been a downside to vertical slicing in Pheonix but the conversations I am thinking of might be out of date. Hence curious, are you doing vertical slicing? How’s it going? Any pros or cons you think are worth sharing or advice for anyone thinking about using the architecture in their next app?


Please note the four posts below have been moved here from another thread.

Most Liked

sodapopcan

sodapopcan

I often organize the web directory by feature as opposed to by type, but I strong prefer to draw a hard line between the domain and web layers. Contexts are not always 1-to-1 with web sections.

FlyingNoodle

FlyingNoodle

In elixir apps the module names define structure, not the path, so you can already do something like this in phoenix anyway?

foo/
foo_web/
├─ feature_1/
│  ├─ components/
│  ├─ liveviews/

maybe I’m completely misunderstanding your question.

sodapopcan

sodapopcan

I’m finding it very hard to write a succinct answer to this, lol, as it can get really into the weeds with certain designs. I do mean Phoenix, though, yes.

I believe here we’re talking about also including the domain layer, so the structure would really be:

foo/
├─ feature_1/
│  ├─ components/
│  ├─ liveviews/
│  ├─ context.ex

BUT, maybe I’m misunderstanding but I don’t think so?

Otherwise, @AstonJ a quick example is that I have a client app which is for managing a catalogue of artwork for a visual artist. The app has several LiveViews but there are two that both deal with listing artwork, one for the artist to manage her catalogue (this one is super complex with different views and tons of info) and one client facing that simply lists out all the artwork and allows them to requests licenses for them.

This is where I don’t want to get too much into the weeds because I could totally have two contexts here (with different schemas), one that lists artworks in the context of the artist herself looking at them, and one for clients to browser. I made the intentional decision to forgo this and simply have a flag on an artwork which says whether it can be shown for licensing or not. SOOOO, the Catalog context gets used in both the artwork management feature, and the “license requesting” feature. It’s a bit simpler but does mean I have to deal with ensuring some fields can’t be shown to my client’s clients.

Otherwise, I like to have that firm line between domain and web because I want the domain layer to be able to operate entirely on its own. The web layer is simply a client, IEx is another. But maybe I just need to see a really good example of vertical.

Where Next?

Popular in Discussions Top

Donovan
Hello everyone, I’m so glad to have discovered this awesome community. Thanks for creating it! This is my second post, and apologies for...
New
nunobernardes99
Hi there Elixir friends :vulcan_salute: In a recent task I was on, I needed to check in two dates which of them is the maximum and which...
New
AlexMcConnell
The reason that Rails is as popular as it is is because it’s very easy for relatively inexperienced developers to get a lot of work done....
588 19652 166
New
Crowdhailer
I’ve been hearing much about the new formatter and it’s something I have been keen to try. I find examples buy far the most illuminating...
248 19327 150
New
mbenatti
Following https://github.com/tbrand/which_is_the_fastest |> https://raw.githubusercontent.com/tbrand/which_is_the_fastest/master/imgs...
New
rower687
Hi all, I’ve been reading a lot about the “let it crash” term and how supervising processes and the whole messaging passing make an elixi...
New
rms.mrcs
A couple of days ago I was discussing with a friend about different approaches to write microservices. He said that if he was going to w...
New
joeerl
I’m playing with Elixir - It’s fun. I think @rvirding does give Elixir courses these days. Re: files and database - when I given Erlang ...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
New

Other popular topics Top

New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 43487 311
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 52673 488
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement