This message was imported from the Ruby/Rails Modularity Slack server. Find more info in the import thread.
Message originally sent by slack user U782CX14HG5
We don’t use Rails at Stripe, but we do have a modularization system. Something that makes Stripe unique is our use of Sorbet. We split our codebase into separate “packages,” and I think the biggest challenge being faced right now is mapping out dependencies between packages.
<@U782CX14HG5> that’s very interesting. We (Shopify) have built our own mechanism for packages and are also seeing straightening out the dependency graph as one of the hardest problems.
I’d love to hear more on currently ongoing work - and can also share more about ours.
I think it’s picked up again recently. I’m actually not in-depth familiar with Stripe’s plans, I joined the company just a few months ago and am on a product team.
But right now, dependency boundaries are loosely enforced (via the prison-guard Rubocop stuff you mentioned). We’re working on stronger enforcement mechanisms.
Seems similar to our situation. <@U782WV6188T> knows more about the current state of our packaging tooling (packwerk), but we’re currently weaning it off rubocop.
We’re also working on using selective code loading via gems and Rails engines for stronger boundary enforcement.
“Prison Guard” is what Stripe calls its custom Rubocop rules. I think it’s a tongue-in-cheek reference to a “cop” that “guards” Stripes (ie, prisoners)
In the context of dependency management, Stripe’s packaging system requires that each package declare its dependencies on other packages. And by using “prison guards,” we enforce that you can’t (a) access the private components for other packages, nor (b) access packages that you haven’t declared a dependency on.
That package declaration system is in turn used to drive the code loading process. Unlike Rails, Stripe doesn’t force a convention between file paths → class/module names. But with the packaging system, we can guarantee that dependencies are loaded before the code inside of a package runs.
We’re looking into Rails Engines as separate units of autoloading that can be switched on and off, as have other companies - there was even a talk at this year’s rails conf about it.
That mechanism can be used to enforce dependencies.