Cyclic Dependency occurs when objects form an infinite recurring dependency graph. The head points to the tail and the tail points to the head.
Questions tagged [cyclic-dependency]
123 questions
1
vote
0 answers
Haskell: handling cyclic dependencies while tying the knot
While writing a programming language that will feature local type inference (i.e. it will be capable of inferring types with the exception of function parameters, like Scala), I've run into a problem with cyclic dependencies.
I perform…

SongWithoutWords
- 471
- 5
- 12
1
vote
1 answer
Angular2: Resolving a cyclic dependency between Http intercepting factory and auth service
I have the following auth service:
@Injectable()
export class AuthService {
//...
constructor(private http: Http, private router: Router) {
//...
}
public login(username: string, password: string): Observable {
// perform…

Aakash Jain
- 1,963
- 17
- 29
1
vote
2 answers
Cyclic import in Python makes impossible to call function from the upper module
Here is my code below.
main.py:
import moduleA
print('It works!')
moduleA.py:
import moduleB
def functionA():
return 0
moduleB.py:
import moduleA
globalVariableFromModuleB = moduleA.functionA()
If I run it, I get the error message:
$ python…

Alexander Samoylov
- 2,358
- 2
- 25
- 28
1
vote
0 answers
Nodejs Cyclic Dependency with Revealing Module Pattern
I've been running into this issue lately and am looking for a good solution.
Below is the basic setup.
In c.js, a is an empty object. Currently I got around this by putting the var a=require('./a.js') inside the function (cFunction) that needs…

David
- 494
- 1
- 4
- 11
1
vote
4 answers
How to recurse over items having cyclic dependencies
I'm looking for a better way of recursing over items that may have cyclic dependencies. Currently, I pass a list of already processed items along in order to not process them again, but that is probably not the best way to do it.
Here's what I'm…

Daniel
- 321
- 3
- 10
1
vote
1 answer
Linking multiple header files to c files
How would I go about linking 2 header files that depend on each other with their c files?
For instance I have a file stack.h that depends on a struct declared in linkedlist.h, and the file "stack.c" calls on functions from linkedlist.c which depend…

FreeStyle4
- 272
- 6
- 17
1
vote
2 answers
Hacklang — Why can't I make a nullable cyclic typedef?
I'm trying to implement a recursive container-like structure, and I can understand why a vanilla cyclic typedef would be impossible to realize, but why is the following disallowed as well?
typedef cycle = shape('cycle' => ?cycle); // Cyclic typedef…

concat
- 3,107
- 16
- 30
1
vote
2 answers
How to Break Cyclic Dependencies in Design
I am searching for a design solution to the problem where I have 2 classes which depend on each other such that I have class Customer and class Order where:
Customer can have a list of orders (1-to-N) and an Order has a designated customer (1-to-1).…

Koray
- 467
- 1
- 5
- 12
1
vote
1 answer
Finding the all cyclic dependencies in directed graph using Perl
I am looking for the solution to a problem where Perl script could detect all the cyclic nodes in a directed graph?
For example, I have following graph:
A<-N<-G<-L<- A<-B<-C<-D<-E<-F<-A Be a Graph with cyclic edges.
use strict;
use warnings;
my…

Analyzer
- 79
- 7
1
vote
1 answer
C++ linker order of library with cyclic dependency
I have two classes One and Two present in two individual cpp files. The contents are as follows
#include "One.h"
#include "Two.h"
namespace Sample
{
One::One() {}
void One::foo1() {
Two t;
t.foo();
}
void One::foo() { …

Shivanand Naik
- 11
- 3
1
vote
1 answer
Converting UML class diagram to C++ code(VS 2012)
I am using VS2012 for a course project that we started from scratch, We are to use C++ to create something like this (I think the aggregation part is reversed):
https://www.dropbox.com/s/w2zh7yltbups6cm/class.png
Well , we had that on paper , wrote…

Maverick
- 62
- 1
- 9
1
vote
1 answer
Ninject cyclic dependency - already using property injection
I'm having a problem with a cyclic dependency in a project using dependency injection. In looking around, it seems that the only way to avoid it, other than restructuring (I did some of that too), is to use property injection. I tried this, and it…

Ixonal
- 616
- 8
- 18
1
vote
1 answer
Cyclic dependency between functions in F#
I am trying break this cyclic dependency below but not sure the best way to do it.
let cashOpeningBalance t =
if t = 1 then
0.0
else
cashClosingBalance (t - 1)
let cashInterest t =
cashOpeningBalance t * 0.03
let accumulatedCash t =
…

jeremyh
- 612
- 4
- 14
0
votes
2 answers
Backend module needs URLs from presentation layer - how to avoid cyclic dependency?
URL generation in my web app is in charge of the presentation layer.
Now consider another module sending out messages containing URLs. (Not necessarily triggered from presentation).
However, the presentation layer has to know about the module (since…

peter p
- 778
- 5
- 14
0
votes
0 answers
Class initialization trouble: static variables are null when accessed
I have a complicated problem in a Java system. Here is a glimpse at it:
public class Foo {
public static final Foo FOOBAR = Bar.VALUE;
...
}
public class Bar extends Foo {
public static final Bar VALUE = new Bar(...);
...
}
In this case, I…

Gunther Schadow
- 1,490
- 13
- 22