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
23
votes
3 answers
How to resolve a circular dependency while still using Dagger2?
I have two classes, Foo and Bar, which depend on each other, as well as various other classes. I am using Dagger-2 for dependency injection, but if I naively add the circular dependency, Dagger hits a stack overflow at runtime. What's a good way…

Jesse W at Z - Given up on SE
- 1,720
- 1
- 13
- 35
22
votes
4 answers
OO design and circular dependencies
I am currently struggling with a circular dependency problem when designing my classes.
Ever since I read about the Anemic Domain Model (something I was doing all the time), I have really been trying to get away from creating domain objects that…

Ben J
- 5,811
- 2
- 28
- 32
21
votes
2 answers
circular generic type parameters
I have 2 generic classes, a BaseComponent Class, and a BaseManager class.
They're both abstract and are intended to be made concrete.
public abstract class BaseManager where T : BaseComponent>
public abstract class BaseComponent where T :…

George Duckett
- 31,770
- 9
- 95
- 162
21
votes
1 answer
sqlalchemy.exc.CircularDependencyError: Circular dependency detected
The business logic - One Category may have multiple (1:M) attributes, like Category "Memory" could have attributes Speed, Size, Type etc.
at the same time one Category could be sorted by the attribute value (this is stored inside…

DmitrySemenov
- 9,204
- 15
- 76
- 121
20
votes
4 answers
What is a circular dependency and how can I solve it?
Scenario
I have a solution on which I have (more than) 2 projects.
The first project has a project reference to the second project. The second project doesn't have a reference to the first project.
Well, in the first project I defined a inheritable…

ElektroStudios
- 19,105
- 33
- 200
- 417
20
votes
2 answers
Is circular dependency good or bad
I need to know why we need to avoid circular dependencies?
In the real world if we think, circular dependencies are pretty much important. Like one friend needs something from other friend and the other needs something from this friend, so its kind…

Nipun
- 4,119
- 5
- 47
- 83
20
votes
2 answers
In what .NET languages can a class derive from its own nested class?
In C#, trying to compile the following code yields an error, "Circular base class dependency involving 'A' and 'A.B'"
public class A : A.B
{
public class B { }
}
However, I am looking at a 3rd party DLL via a decompiler, and seeing this…

Omer Raviv
- 11,409
- 5
- 43
- 82
20
votes
5 answers
Python module dependency
Ok I have two modules, each containing a class, the problem is their classes reference each other.
Lets say for example I had a room module and a person module containing CRoom and CPerson.
The CRoom class contains infomation about the room, and a…

Fire Lancer
- 29,364
- 31
- 116
- 182
20
votes
1 answer
Is it possible to import flask configuration values in modules without circular import?
I'm using Flask with Blueprints to get a skeleton for my website and I'm having a problem using configuration classes deep in my application.
Here's some dummy code that explains how I've set everything up:
websiteconfig.py
class Config(object):
…

moodh
- 2,661
- 28
- 42
19
votes
1 answer
Does Objective-C allow circular dependencies?
I'm rewriting a Java library in Objective-C and I've come across a strange situation. I've got two classes that import each other. It's a circular dependency. Does Objective-C support such a situation? If not, how do you recommend I rewrite it?

Moshe
- 57,511
- 78
- 272
- 425
19
votes
5 answers
Circular Dependency in C++
The facts:
I have two predominant classes: Manager and Specialist.
There are several different types of Specialists.
Specialists often require the help of other Specialists in order to get their job done.
The Manager knows all of the…

JnBrymn
- 24,245
- 28
- 105
- 147
19
votes
5 answers
Resolving Clojure circular dependencies
I'm working on some Clojure code that has some circular dependencies between different namespaces and I'm trying to work out the best way of resolving them.
Basic issue is that I get a "No such var: namespace/functionname" error in one of the…

mikera
- 105,238
- 25
- 256
- 415
19
votes
1 answer
Compiler error C4430: missing type specifier - int assumed
I have this error:
"error C4430: missing type specifier - int assumed. Note: C++ does not support default-int"
with this code example :
//A.h
#include "B.h"
class A{
B* b;
..
};
//B.h
#include "A.h"
class B{
A* a; // error error…

user3571201
- 203
- 1
- 2
- 6
19
votes
2 answers
Objective C - Error: 'Expected a type'
I'm getting a very strange error on something that I would have thought to be simple.
#import
#import "ViewController.h"
#import "GameObject.h"
@interface GameController : NSObject
@property (strong) GLKBaseEffect *…

user2577959
- 285
- 1
- 2
- 6
18
votes
2 answers
Clean way to deal with circular references in EF?
Say I have this table structure:
Client
-----------
ClientId int not null (identity)
CurrentDemographicId int null (FK to ClientDemographic)
OtherClientFields varchar(100) …

Vaccano
- 78,325
- 149
- 468
- 850