My experience has been that shitty code tends to be shitty because it accesses &quot;magic global state,&quot; so it&#x27;s hard to coral it into a single module almost by definition.  This happens usually because of rushed deadlines; it&#x27;s often hard to plumb through an extra parameter if there are many touchpoints or a lot of tests to fix, and easier to just stuff something into a global variable and ship the code.