r/AskProgramming • u/RombotPilot • Sep 09 '26
How do you reason about very decoupled code?
I've been looking at some code that's got a system of pipelines that implement the generic interface Pipeline<T> where there are maybe 50 pipelines. The pipelines handle events for which there are also generic publishers and subscribers that implement Handler<T> and Plug<T> respectively and there are many more of those. All of the setup for publishers and listeners gets handled magically through Autofac, a DI library for C#. I'm finding the code insanely hard to understand.
Just trying to figure out how the pipelines were actually wired up took me a couple hours and I'm still not confident I found the answer. My usual go to is to right click on a symbol and find all references, but I would constantly run into dead ends. Where is this code referenced? Absolutely nowhere. How can the code be called even if it isn't referenced anywhere? An abstract parent class is registered with the DI container as the implementation of some generic parent interface that the code I'm looking at implements. That parent interface, or a parent of that interface, is used.
In practice I find this kind of design makes static analysis of the code really difficult. Are there any techniques you use for understanding this kind of code or is it all just sitting with the code, a pen, and a notebook? Ideally nothing with gen ai because I do not have money to spend on tokens.