Dependencies and programmatically avoiding circular references

Many thanks @al2o3cr and @Tyson for your input.

The “plan B” for this problem that I’ve put in place is just to concede, for now, that these development oriented functions are just most naturally part of the application Components. So instead of, say, database related functions going into a DbDevUtils, they just are now part of Db. The biggest downside is that this means these dev/test helper functions will be in production and release builds: while they shouldn’t interfere with normal operations, they do increase the overall theoretical attack surface of the modules and are the sort of cruft that can get misused if available in contexts where they shouldn’t be available.

Admittedly, part of my motivation in asking my question was also to ask a question behind the question: “how far can the conditional compilation techniques that are well supported at the top level be pushed into dependency compilation.”

I agree and its been my “second best” option. Indeed having committed to this “Component” based application development style, the reason there are separate Db and Flags Components is because of just this kind of analysis. A single DevUtils absolutely breaks this principle and definitely works against the natural organization of the code. The main justification for a single DevUtils is that the functionality being wrapped is so thin it’s easy to swamp the gains from reduced boilerplate & duplication with the overhead of maintaining multiple made for purpose Elixir packages… and there’s a little extra cognitive load cost increase for understanding what is essentially dev/test tooling… which just isn’t the context I want to spent my “available cognitive load”. So my quest was very much in the vein of “wanting to have my cake and eat it too”.

I would disagree with this characterization. There are conditional compilation techniques which are well supported and the question wasn’t geared to finding some sort of “loophole”, “bug-as-feature”, or a “one weird trick” kind of answer; it was really about how far down do the supported conditional compilation techniques get pushed and that I might not be aware of. If a conditional compilation method is supported, I would argue that’s not a “crazy dance to make the compiler happy”, but “making use of a supported feature to achieve a goal”. At that point we can argue about whether the goal is worthy, but the technique itself shouldn’t be in question.