Questions tagged [circular-dependency]
The circular-dependency tag has no summary.
54 questions
52votes
3answers
121kviews
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 ...
27votes
5answers
4kviews
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(...
24votes
10answers
6kviews
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 ...
16votes
5answers
26kviews
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 Worker{...
7votes
2answers
6kviews
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 ...
6votes
2answers
5kviews
How to easily avoid circular dependencies
In a legacy project's service layer, there are tens of service classes and among them there is one service, UtilityService using 2 other services: class UtilityService{ private UserService ...
5votes
3answers
20kviews
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 ...
5votes
3answers
868views
How to avoid DI dependency cycle for observer pattern
In my project I'm using the observer pattern in several places, i.e. the subject notifies the observers about something, and expect them to act. The subject does not know anything about the details of ...
5votes
1answer
2kviews
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. +------------------+ +---------...
4votes
4answers
7kviews
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 ...
4votes
3answers
3kviews
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 ...
3votes
3answers
209views
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 ...
3votes
1answer
419views
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 ...
3votes
4answers
685views
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(); ...
3votes
2answers
3kviews
Is circular reference with Typescript array properties bad design?
I understand that having circular dependency can be bad design. However, I have a question regarding a certain class structure. As an example: ocean.ts import {Boat} from './boat'; export class ...