This is the second part in my little series about dependency anti-patterns. The first part was about the God Node. Images and nomenclature are based on Degraph.
As long as the affected nodes are collapsed the Bypass looks just like any circular dependency.
But if you expand them something strange happens. In one node (A) (the main road so to say) one part of the subnodes gets pushed to the left (A1), while the rest gets pushed to the right (A2). The A1 nodes depend on B (the actual bypass) and B depends on A2. Since all arrows still go from left to right it can get hard to spot the problem, when more nodes are involved.
I have seen this many times when someone attempted some kind of dependency injection, but didn't complete it. Maybe B is a plugin like class implementing a feature for an application A. For this it implements some kind of plugin interface A2, so that A doesn't actually need to know B. But something (A1) has to plug everything together, so it has to know A1 and B. That is ok, it just shouldn't be in the same node as A2.
Which already gives a fix to this kind of problem: Move A1 (or A2) to its own node, basically splitting A in two pieces, voila you just got rid of a circular dependency. An alternative is to move A2 into B. The correct decision depends on the semantics of the nodes involved.
Talks
Wan't to meet me in person to tell me how stupid I am? You can find me at the following events: