This message was imported from the Ruby/Rails Modularity Slack server. Find more info in the import thread.
Message originally sent by slack user U71810IPUMS
My company’s monolith currently is a mess. I am trying to champion a refactor towards modularity; however, we have a fairly nested structure. What I mean by that is that we have pieces of business logic that would be great to put in chuck but that base on the type of product (and sometimes its subtype) the logic differs. As such we have app/services/complex_doer.rb that conditionally call app/services/product_type/complex_doer.rb which in turn may call app/services/project_type/subtype/complex_doer.rb . Can packwerk or something similar do nested structure and is there maybe a better way entire of doing this?
It should be noted that the various complex_doers are calling out to command services and other thing, hence my desire to put them in packs. Especially as ideally, the application should only ever touch the top-level service
You could start just by creating packs from the “big” concepts in the app and then potentially create child packs. And then you can create the public API surface for those so things aren’t reaching down into them… but I’d just start with what you think makes sense and then use packwerk to help figure out where the demand is for those APIs.
Packwerk does support nested packages, depending on what behavior you expect. Today, it doesn’t treat nested packages any different than any other pack. For example, packs/a and packs/b/ can both have a privacy/dependency violation on packs/a/c
Those sound doable. In my example, the goal would be to never call anything lower than packs/a and that packs/a/c would be private to everything except packs/a
Does it only support one layer (i.e. packs/a/c) or can it go deeper? In other words, could I have packs/complex_doer/product_type/subtype/path/to/file.rb?
and that packs/a/c would be private to everything except packs/a
Packwerk doesn’t support enforcing this today. However – in packwerk 3, we are releasing extensible checkers. One of the first new checkers I’ll be releasing is a “visibility” checker. This means you’ll be able to specify explicitly that only packs/a can use packs/a/c, even if the other packs (e.g. packs/b) have listed packs/a/c as a dependency and are using public API.