circular dependency is a relation between two or more modules which either directly or indirectly depend on each other to function properly.
Questions tagged [circular-dependency]
1693 questions
9
votes
2 answers
Rails 4 Runtime error in controller: Circular dependency detected while autoloading constant
Let me know if I left anything out. I can't figure out why my views/references/ folder isn't accessible. neither new.html.erb nor index.html.erb is available. When I go to localhost:3000/references my error is:
RuntimeError in…

user3138341
- 219
- 2
- 3
- 12
9
votes
2 answers
Avoiding a nested service locator antipattern with DI / autofac
I had something of a convenient service locator anti-pattern in a previous game project. I'd like to replace this with dependency injection. autofac looks like the most likely DI container for me as it seems to have relevant features - but I can't…

El Zorko
- 3,349
- 2
- 26
- 34
9
votes
1 answer
Visual Studio 2012 - Find Circular References Efficiently
Currently if I want to check for circular references inside a solution I select Architecture - Generate Dependency Graph - For Solution.
Then from the new tab that opens I select Layout - Analyzers - Circular References Analyzer.
Finally if I drill…

RobSullivan
- 651
- 2
- 7
- 15
9
votes
1 answer
Difference between "import lib.foo" and "import lib.foo as f" in Python
I'm puzzled by how circular imports are handled in Python. I've tried to distill a minimal question and I don't think this exact variant was asked before. Basically, I'm seeing a difference between
import lib.foo
and
import lib.foo as f
when I…

Martin Geisler
- 72,968
- 25
- 171
- 229
9
votes
3 answers
Circular Dependencies in modules using requireJs
Reading the requireJs documentation,
in order to fix the Circular Dependencies, is suggested to use exports to create an empty object for the module that is available immediately for reference by other modules.
I try this code but it seems to do…

Lorraine Bernard
- 13,000
- 23
- 82
- 134
8
votes
3 answers
Use Current Template as a Template Parameter to one of the Template Parameters
I am trying to make a generic graph structure, but I am running into this circular dependency between vertices and edges. I define my Vertex and Edge classes like so:
template
struct Vertex {
std::vector…

Simon Berens
- 554
- 4
- 11
8
votes
0 answers
How to use constants with string interpolation in Angular routes declaration?
Route segments have been moved to constant. The code below is simplified, but in project about 5 lazy modules, each have about 20 routes, and segments often used in services and components for router.navigate and as string keys in objects (f.e.…

Nikita
- 1,019
- 2
- 15
- 39
8
votes
1 answer
ES6 Modules and Circular Dependency
I'm having this problem in ES6 in a Babel Environment:
// A.js
class A {
}
export default new A();
// B.js
import C from './C';
class B {
}
export default new B();
// C.js
import A from './A';
import B from './B';
class C {
constructor(A, B){
…

Leonardo
- 4,046
- 5
- 44
- 85
8
votes
1 answer
Angular: How to resolve circular dependency between directive and component?
I have a RadioButtonComponent and a RadioButtonGroupDirective which depend on each other:
RadioButtonComponent:
import { RadioButtonGroupDirective } from "./radio-button-group.directive";
...
constructor(@Optional() @Inject(forwardRef(() =>…

Shackles
- 1,264
- 1
- 19
- 40
8
votes
6 answers
Resolving circular depenency
I have two class projects in a Visual Studio solution. Due to the nature of th project both projects reference each other because they need each other's services (think of the "I scratch your back, you scratch mine" phrase).
Visual Studio (2010)…

GurdeepS
- 65,107
- 109
- 251
- 387
8
votes
2 answers
Why is circular dependency allowed with namespaces in c#?
In c# you're allowed to have a statement in file a.cs (which has namespace of MyApp.A):
using MyApp.B;
while file b.cs (which has namespace of MyApp.B) already have the statement
using MyApp.A;
If a similar dependency would exist in different…

BornToCode
- 9,495
- 9
- 66
- 83
8
votes
1 answer
How to solve circular dependency in Require.js?
Basically, the idea is that "sub" module creates an object, and that object should be part of a utilities library which is the "main" module. However, the "sub" object depends on utilities from "main":
// Main module
define(['sub'], function(sub) {
…

pilau
- 6,635
- 4
- 56
- 69
8
votes
2 answers
Avoid Circular Dependency
I am developing a travel management application. The design in question is something like following :
Each person in a tour is designated as a Traveler.
Each Traveler has a Passport.
Now, a Traveler can be a MainMember or a SubMember, depending on…

bhootjb
- 1,501
- 1
- 21
- 33
8
votes
4 answers
Why is there no cyclic layout issue for classes in C#?
public struct Unit
{
Unit u;
}
Causes:
Struct member 'Unit.u' of type 'Unit' causes a cycle in the struct
layout.
But
public class Unit
{
Unit u;
}
compiles. I understand the problem I suppose. An endless cycle will be formed when…

nawfal
- 70,104
- 56
- 326
- 368
8
votes
2 answers
Typedef Circular Dependency
How can I solve the following circular dependency?
typedef boost::variant Value;
typedef std::list> Structure;
typedef std::vector ValueContainer;
I'm…

Baz
- 12,713
- 38
- 145
- 268