Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [circular-dependency]

The tag has no usage guidance.

0
votes
1answer
24 views

Removing an Object from its holder

Let's assume I have three classes, as follwing: class A { Array<B> bs; createB() { b = new B(); this.bs.insert(b); return b; } } class B { Array<C> cs; createC() { c = new C(); ...
1
vote
0answers
57 views

How can I resolve circular dependency within service layer in a n-tier architecture system?

I am currently starting a new project with a 4-tier architecture design. The layers is set as follow. +------------------+ +---------...
4
votes
3answers
768 views

Resolving circular dependency between two classes

I am trying to resolve a circular dependency between two components in my system. The Messenger component is responsible for sending and receiving messages on a web socket. The Controller component ...
3
votes
3answers
535 views

Is 2 methods calling each other code smell?

For example, if 2 classes depend on each other, it is a kind of circular dependency and should be avoided. How about methods? for example, if I have 2 methods which call each other: public void ...
0
votes
3answers
142 views

Circular dependency in composition root

I have a MDI MyMDIWinForm that needs an instance of IGUIErrorHanlder for error handling, At the same time IGUIErrorHanlder depends on the MDI MyMDIWinForm for having a place from where to launch pop-...
4
votes
1answer
145 views

Circular dependency problem

"Single item in a set depends on the whole set. Set depends on that item." I'm creating a compiler (https://github.com/SuperJMN/Plotty). In the last stage, the Intermediate Code is converted to ...
3
votes
4answers
173 views

Circular Interface references

I've heard circular references are generally an issue, however I was wondering if this was true for interfaces that reference other interfaces, for example: IQuestion{ IAnswer getCorrectAnswer(); ...
1
vote
2answers
633 views

Callback injection

I have a service that needs to make a callback. Basically, it is an event that is expected to be handled in exactly one place, and that is too important to be optional. The obvious approach seems to ...
-1
votes
3answers
196 views

Refactoring - Resolve dependencies between legacy code used by third parties

I am developing two libraries in .Net Firs one it's a library with core functionality (named it Library.Core.dll) Let's focus in User class public class User { //set of constructors and ...
1
vote
2answers
1k views

Remove circular dependency

I have 2 classes that have dependencies. public class AuditManager { //set of methods public static AuditManager Singleton= new AuditManager(); public int AuditEvent(int x){ ...
1
vote
2answers
630 views

What other approaches are there to break circular dependency in MVC?

I'm attempting to build a web front-end based on the MVC pattern, as opposed to based on the libraries involved (e.g. React.js). I'm using constructor-based dependency injection and interfaces to de-...
3
votes
3answers
169 views

What is the motivation or usage to create a interface use once only just for breaking circular dependency?

I understand if 2 classes have circular dependency, eg: public class MyWindow{ public MyWindow(){ new MyDialog(this); } public onDialogResponse(int option){ } } public class ...
5
votes
2answers
2k views

What are the potential problems with operational circular dependency between microservices

I am relatively new to microservice architecture and I was never before involved in a project where the architect insists on having a circular dependency between services. I am in a position without ...
4
votes
1answer
68 views

Logging an error and creating an error when the logging fails create a circular dependency between two projects

As part of a program I am developing for practice purposes, I've created a namespace Core designed to contain the core code resources for the program to use. This namespace is in a Class Library ...
-1
votes
3answers
556 views

Architecture, database design, avoid a circular reference

I have to design a database in a Rails application, where I have users (who can login), companies and jobs. Each user belongs to a company, and each job belongs to a company, so when a user logs in, ...
22
votes
5answers
2k views

How to model a circular reference between immutable objects in C#?

In the following code example, we have an class for immutable objects that represents a room. North, South, East, and West represent exits into other rooms. public sealed class Room { public Room(...
0
votes
1answer
75 views

Mutual observer

I want my Wire objects to be in connection with Port objects. That is Port has a list of connected wires and method Port.add(wire). Similarly, Wire has list of ports it is connected to and Wire.add(...
1
vote
2answers
380 views

Help with getting rid of circular dependency

I have the following circular dependency that I'd like to eliminate. I think I must have a flaw in my design. And I'd much appreciate any feedback on how to fix this. My circular dependency comes ...
0
votes
1answer
67 views

Reflexive calls of objects in the same hierarchy

I am not sure how to phrase this. I believe this should have been asked somewhere, but I am unable to find it because I don't know the keywords. Basically, I have some types like this: interface Foo ...
7
votes
5answers
6k views

If A has B and B holds reference of A, is it a flawed design need to be fixed? [duplicate]

Suppose, I have class Boss and Worker; Boss has a Worker and Worker holds a reference of Boss: Boss.h #include "Worker.h" class Boss{ public: Worker worker; }; Worker.h class Boss; class ...
1
vote
2answers
881 views

How to remove circular reference when there is inter-dependence

I made an extensive research in previousv related questions, but since my questions is somewhat peculiar, I decided to create this new one. I am implementing a visualisation application (in JS). ...
0
votes
0answers
122 views

Should I reference both up and down a hierarchy when using Entity Framework?

Let's say I'm modelling an organizational hierarchy which consists of Divisions that contain Departments that contain Teams. So Division -> Department -> Team. While it makes sense for the Division ...
1
vote
4answers
177 views

File-Directory Implementation: Does a a file have to own a reference to it's dir?

I am currently issuing a problem while forming the program-design, which is exact like a File-Directory relationship, and to ease it, I am using that as an example. I think it is usual, that a ...
1
vote
3answers
191 views

What was the first language that allowed a class to contain a member of it's own type

So, I had to create a class that had a member of it's own type. I looked into why this was possible, which is fascinating. Reading the answer, I find that a lot of work had to go into making this work,...
0
votes
4answers
621 views

Circular dependencies: Recursive grammar parser (e.g. json)

(TLDR) To build a parser for a recursive grammar by composition of individual parsers (e.g. with a parser combinator framework), there are often circular dependencies between some of the individual ...
27
votes
3answers
41k views

How to solve circular dependency?

I have three classes that are circular dependant to each other: TestExecuter execute requests of TestScenario and save a report file using ReportGenerator class. So: TestExecuter depends on ...
2
votes
2answers
989 views

Designing classes that depend on each other

How would one go about designing classes for a system in which two components depend on each other? For a more concrete example, consider this scenario, you're designing a piece of software to manage ...
3
votes
1answer
447 views

How to calculate number of indirect dependencies of a class?

Most of the static code analysis tools which analyse class dependencies generate dependency pairs of classes where each pair represents a direct dependency between two classes. Given those dependency ...
2
votes
0answers
476 views

Refactoring to avoid circular references

I'm working on an ASP.NET MVC solution that has two projects, WebUI and DAL. WebUI references DAL. DAL has the repository and context, while WebUI contains Authentication and Authorization classes. ...
24
votes
10answers
5k views

What's the proper way to model this real-world activity that seems to need circular references in OOP?

I've been wrestling with a problem in a Java project about circular references. I'm trying to model a real-world situation in which it seems the objects in question are interdependent and need to ...
-2
votes
1answer
363 views

Base Class, with method that returns Derived Class. design flaw?

I'm writing a Math equation solver in python (for fun). The first design that came to my mind: Expression: base class for every item in an equation (maybe bad name). BinaryExpression extends ...
1
vote
4answers
3k views

Circular dependency and object creation when attempting DDD

I have a domain where an Organization has People. Organization Entity public class Organization { private readonly List<Person> _people = new List<Person>(); public Person ...