Will being able to organise/work on individual components of an app by component directories be possible with Hologram?

Interesting - I hadn’t thought of it like that, but I guess if Hologram is always going to ship with Phoenix then you’ll always have Phoenix and all of its benefits. This does sound very appealing!

And in that case something I would really love, and not sure if Bart has thought of this, is a way to build my apps as a series of components. I think Phoenix Contexts does this in a way, but I’d love to build apps as a series of components that are reflected in the directory structure. Many frameworks are centred around directories for Models/Views/Controllers etc, but I’d like directories for components and then each related file in there, with MVC directories if need be. This just makes it easy to work on individual parts as well as easily being able to slot in/out different versions (which could be almost nothing like each other). It just feels right to me and I think would be very attractive to developers as working on individual parts of an app in this way would feel a lot less overwhelming than working on one big one, enabling solo devs or small teams to tackle or focus on one thing at a time, rather than the whole thing.

2 Likes

I think what you’re describing is vertical slicing architecture - and I have great news! This is exactly what will be possible in the standalone Hologram version. Actually, supporting this kind of structure is one of the key reasons why standalone is needed.

Here’s how it will work:

When you generate a new project with the Hologram project generator, you’ll start with a horizontal slicing structure - all your app directories organized by technical layers (pages, components, services, etc.) in one flat folder structure.

But as your application grows (or really, whenever you want), you’ll be able to switch to vertical slicing and reorganize the app folder into feature/domain directories like shopping_cart, accounting, etc. Each subfolder would have its own subdirectories for pages, components, services, tests, and so on.

I think it usually makes sense to start with horizontal slicing because in the beginning you don’t always know exactly what you’re building, and this way you can save time not overthinking boundaries (similar to how you’d start with MVC). Later, once the application grows and patterns emerge, you can reorganize the code better.

Note: Vertical slicing won’t be possible in the first standalone version, but it will be supported eventually.

So Hologram will have two modes:

  1. Embedded - where you use Hologram alongside Phoenix or even together with Phoenix LiveView
  2. Standalone - very simple to use, with a very simple structure, no configuration needed. Just install and start adding features.
5 Likes

Ah this is awesome! For me, being able to tackle and focus on one part of an app at a time is a huge plus - not just in the initial make-a-start phase (far less overwhelming if you break an app into smaller components) but I feel you are also more likely to actually spend more time on each component as well as continuing to go back to them to refine them, because they’re self-contained meaning you don’t have to overstretch your bandwidth (which at times can often be limited if we’re busy/stressed out/working towards deadlines/etc).

Let’s split these posts into a separate thread in case anyone else is curious or wants to add their thoughts too :icon_biggrin:

2 Likes

4 posts were merged into an existing topic: Vertical slicing architecture in Phoenix - anyone doing it? Pros/cons?