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.
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.
Do you mean in Phoenix? Are there any example repos around (or could you create a dummy) for us to look at? And does it create any problems or feel like it’s going against the Phoenix-way?
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:
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.