circular-dependency

Is circular dependency good or bad [closed]

邮差的信 提交于 2019-12-04 05:05:43
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 of circular right? Then why is circular dependency a bad design? If we really need to avoid this then what is the best possible design in Object oriented world for such a situation? The problem with circular dependencies is rather like the chicken and egg problem. If you depend on me setting something up, and I depend on you setting something up,

How to resolve a circular dependency while still using Dagger2?

好久不见. 提交于 2019-12-04 02:08:51
I have two classes, Foo<T> 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 to refactor the classes to fix this, while still using Dagger to inject all the other dependencies, and with minimal duplication and changes to existing calls? The easy way out is to use Lazy<T> on one side. Lazy<Foo> foo; @Inject Bar(Lazy<Foo> foo) { this.foo = foo; } // use foo.get(); when needed After an excessive amount of thought and talks

OO design and circular dependencies

早过忘川 提交于 2019-12-03 15:13:50
问题 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 were just "buckets of getters and setters" and return to my OO roots. However, the problem below is one that I come across a lot and I'm not sure how I should solve it. Say we have a Team class, that has many Players . It doesn't matter what sport

How to solve circular dependency in Require.js?

瘦欲@ 提交于 2019-12-03 12:59:53
问题 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) { var utils = { utilityMain: function () { // ... }; // ... }; tools.subModule = sub; return tools; }); // Sub module define(['main'], function(main) { return new (function () { // Singleton object using functions in main module var somestuff =

Resolving circular dependencies with Node.js require and classes in CoffeeScript

孤街浪徒 提交于 2019-12-03 12:52:11
I want to know if there is a way to idiomatically avoid issues with circular dependencies with Node.js's require while using CoffeeScript classes and super . Given the following simplified CoffeeScript files: a.coffee: C = require './c' B = require './b' class A extends C b: B someMethod: -> super module.exports = A b.coffee: C = require './c' A = require './a' class B extends C a: A someMethod: -> super module.exports = B The first obvious issue here is that there is a circular dependency between A and B. Whichever one evaluates first will have {} as a reference to the other. To resolve this

Python module dependency

微笑、不失礼 提交于 2019-12-03 07:58:42
问题 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 CPerson list of every one in the room. The CPerson class however sometimes needs to use the CRoom class for the room its in, for example to find the door, or too see who else is in the room. The problem is with the two modules importing each other I

Can I avoid a dependency cycle with one edge being a test dependency?

好久不见. 提交于 2019-12-03 07:43:31
Consider a testCycle parent with modules DummyCore and TestFramework . TestFramework depends on DummyCore , and DummyCore has a test dedepency on TestFramework . Building and testing each module independently maven has no problems. But mvn test the parents testCycle results in: The projects in the reactor contain a cyclic reference: Edge between 'Vertex{label='com.mysimpatico:TestFramework:1.0-SNAPSHOT'}' and 'Vertex{label='org.apache:DummyCore:1.0-SNAPSHOT'}' introduces to cycle in the graph org.apache:DummyCore:1.0-SNAPSHOT --> com.mysimpatico:TestFramework:1.0-SNAPSHOT --> org.apache

Avoid Circular Dependency

你离开我真会死。 提交于 2019-12-03 07:42:34
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 whether or not he is the head of the family. A MainMember decides stuff like TourPackage, total amount for his travelling family, etc. A SubMember is dependent on the MainMember while travelling. So, if a MainMember is deleted, all its SubMembers have to be deleted as well. So, A Traveler has a Passport. (One to One relationship) A Traveler is either

Recommended way to have 2+ modules recursively refer to each other in Lua 5.2

旧时模样 提交于 2019-12-03 07:40:59
Is there a way to have Two Lua modules (let's call them A and B ) Each module uses functions from the other, so they must require each other A third module (let's call it C ) can use A but not B e.g. C.lua : local A = require 'A' -- ... A.foo() There may be another module D that requires B but not A and/or E requiring both A and B Neither A nor B nor their members should be added to the global namespace. Avoid using the module and setfenv functions (deprecated in Lua 5.2) Related : Lua - how do I use one lib from another? (note: this solution does not handle circular dependencies.) I found

Compiler error C4430: missing type specifier - int assumed [duplicate]

戏子无情 提交于 2019-12-03 06:17:06
This question already has answers here : Resolve build errors due to circular dependency amongst classes (11 answers) 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 C4430: missing type specifier - int assumed. }; This is a circular dependency issue. For declaring a pointer to some class, the definition of the class is not needed; i.e. the type doesn't have to be a complete type . So you don't need to include A.h in