Strategies for resolving cyclic dependencies in static ctors
Nick Sabalausky
a at a.a
Tue Mar 22 21:42:23 PDT 2011
"Graham St Jack" <Graham.StJack at internode.on.net> wrote in message
news:imbai9$2jb9$1 at digitalmars.com...
>
> My own solution to this "problem" is to never have circular imports at
> all. The build system I use prohibits them, so any careless introduction
> of a circularity is spotted immediately and I refactor the code to
> eliminate the circularity. I have never come across a valid need for
> circularities, and have never had any trouble eliminating any that creep
> in.
>
> Avoiding circularities has plenty of advantages, like progressive
> development, testing and integration. On bigger projects these advantages
> are very important, and even on small ones they are useful.
>
That's certainly good in many cases, but I find there are many times when a
"one-way" dependency graph just doesn't fit the given problem and causes
more trouble than it solves. You often end up needing to re-invent the wheel
to avoid a dependency, or split/arrange/merge modules in confusing
unintuitive ways that have more to do with implementation detail than
high-level purpose.
More information about the Digitalmars-d
mailing list