Ever since seeing Eileen Uchitelle's RailsWorld 2024 talk, I've struggled with the feeling that discussions of modularity are hampered by a lack of consensus on basic terms.

I wrote a few articles to help sort out my thoughts. The third one is probably the most applicable. https://rossney.net/articles/good-boundaries-make-good-systems/

I'm not writing as an expert or any kind of authority, but I sure would enjoy being part of a conversation that promotes clarity around this topic. Please boost.

#Ruby #Rails #RubyOnRails #Modularity

Good Boundaries Make Good Systems

Good Boundaries Make Good Systems: In this article we will focus on the implications of taking autonomy as our North Star in module design. What are the practical implications? As always, what goes in and what goes out?

I propose four conventions for implementing autonomous modules:

1. Packs/modules are only for domain logic. No controllers, views, or other UI objects allowed.
2. Only coupling between packs/modules should be examined for dependency control (coupling to the UI is expected behavior).
3. Only data objects should be passed to and from packs/modules.
4. Packs/modules must own their own data.

Do you think these make sense? Do you have different ideas? I would love to hear about them.

@dcrossney Interesting ideas. The idea with splitting UI from packs seems to make sense. It makes me think of CQRS. You might be interested in Eventide as well. That community has another take on modularization and autonomy - coming from more of an event sourced angle.

@jacobat

I 💜 Eventide, but they have a strong preference for component-based systems. I would love to work on integrating Eventide (or event sourcing in general) with a modularized monolith system.

I think CQRS also works well with this approach because of the clarity provided by the boundary between UI and domain logic.

@dcrossney How do you imagine a modular monolith and something like Eventide could be integrated? What would you put in the monolith?

@jacobat

One hurdle is that Eventide is written around the convention of Useful Objects and uses a bespoke testing framework. Both are cool, but it creates some friction to integrating with libraries that don't use this style.

Should you mate Eventide with Hanami or Rails and maybe rewrite or wrap the highest level components to avoid this friction? Or should someone make a Hanami-like framework in the Eventide style? 🤔

@dcrossney Why is integration with web frameworks a problem? I understand how eventual consistency makes some classic UI patterns impossible. But beyond that I don’t see much of an issue.

At least I’m imagining that constructing a database with a view of the data should not be that difficult. And putting a webapp on top of that sounds straightforward to me as well.

@jacobat

Well, problem is maybe not the right word. But it would be odd to mix Eventide and, say, Hanami framework objects in the same codebase. They are written in different styles, with important differences. There is also some overlap in functionality, parameter parsing and validation for example. I think it would add to the cognitive overhead of the project.

@dcrossney Ah right. I would not mix codebases. I believe the Eventide maintainers have one repository per component. And keep the Rails parts in separate repos