circular-dependency

resolving circular dependencies with dependency injection [closed]

坚强是说给别人听的谎言 提交于 2019-11-30 05:21:30
I've seen several articles on various websites that propose resolving circular dependencies between .NET assemblies by using dependency injection. This may resolve the build errors but it's not really resolving the circular dependency, is it? To me, there seems to still be a logical error in the architecture. Am I crazy or do others agree 1) this is a less than stellar use of DI, and 2) not the appropriate way to solve circular dependency issues? If you have circular dependencies between two objects, it means you need a third object, on which the two objects will depend on, so they won't

Any good advice about how to avoid import cycle in Go?

拜拜、爱过 提交于 2019-11-29 19:58:12
I'm working on a Go project for a month. The good thing is Go is really highly efficient. But after a month of development I've already got thousands lines of code and many packages . To avoid import cycle is a major issue for me that anytime I got a import cycle error, I have no idea where the problem may be at first time. The Go compiler also only have very simple notice that always not good enough to locate issue quickly like: main.go:7:3: import cycle not allowed . It will only help you to know which file may cause the problem but nothing more deeply. Since import relationship just become

C++: Conceptual circular include problem

本小妞迷上赌 提交于 2019-11-29 17:11:17
I'm making a component based entity system for a game engine. I have an entity class, which has to include the component base class header in order to define the array of components private Component* components[ 123 ] However, in the component base class I have to define a private Entity* ownerEntity , beacuse it is crucial that a component knows who it belongs to! This results in Entity.h needing Component.h and vice-versa -> Circular reference How can I solve this? Ben Jackson As long as you only need your class to contain pointers or references to the other classes, you can skip the real

Circular Dependency in Two Projects in C#

半腔热情 提交于 2019-11-29 13:15:52
I have two projects in a solution named ProjectA (ConsoleApplication) and ProjectB (ClassLibrary). ProjectA has a reference to ProjectB. Generally speaking, ProjectA calls a method in ProjectB to do some stuff and return the results to ProjectA. Sometimes however, I need ProjectB to send some "additional" information to ProjectA (more specifically to call the Console.WriteLine() method in ProjectA). To achieve this, I need to refer ProjectA in ProjectB, but when I try to do that, I get the following error: A reference to ProjectA could not be added. Adding this project as a reference would

Circular Dependency Solution

隐身守侯 提交于 2019-11-29 12:43:02
问题 Our current project has ran into a circular dependency issue. Our business logic assembly is using classes and static methods from our SharedLibrary assembly. The SharedLibrary contains a whole bunch of helper functions, such as a SQL Reader class, Enumerators, Global Variables, Error Handling, Logging and Validation. The SharedLibrary needs access to the Business objects, but the Business objects need access to SharedLibrary. The old developers solved this obvious code smell by replicating

Resolving circular dependencies by linking the same library twice?

我只是一个虾纸丫 提交于 2019-11-29 09:03:44
We have a code base broken up into static libraries. Unfortunately, the libraries have circular dependencies; e.g., libfoo.a depends on libbar.a and vice-versa. I know the "correct" way to handle this is to use the linker's --start-group and --end-group options, like so: g++ -o myApp -Wl,--start-group -lfoo -lbar -Wl,--end-group But in our existing Makefiles, the problem is typically handled like this: g++ -o myApp -lfoo -lbar -lfoo (Imagine this extended to ~20 libraries with complex interdependencies.) I have been going through our Makefiles changing the second form to the first, but now my

solving circular dependency in node using requirejs

人盡茶涼 提交于 2019-11-29 08:02:57
I have been try out many suggestions I found googling for circular dependency in node and requirejs. Unfortunately, I'm not getting it to work. The try which is closed to a solution (I think) is below: // run.js var requirejs = require('requirejs'); requirejs.config({ baseUrl: __dirname, nodeRequire: require }); requirejs(['A'], function(A) { var a = new A.Go(); console.log(a.toon()) }); // A.js define(['B', 'exports'], function(B, exports) { exports.Go = function() { var b = new require('B').Ho(); var toon = function() { return 'me tarzan'; }; return { b: b, toon: toon } }; }); // B.js define

Complex circular dependency

巧了我就是萌 提交于 2019-11-29 07:20:31
what is the the best practice of solving circular dependency in C++ ? I could use the forward declaration, but then I get the pointer to incomplete class type is not allowed error. Does that mean that two classes that uses each others pointer cannot be dependent? Also, I thought about forward declaring each class and then including every header of the solution in the main.cpp , so it's all in one place. Would you recommend it? A snippet from the whole project is below, so you can refer to it if the issue is better explained on an example I'm familiar with, but it would do just to be

Lua: How to avoid Circular Requires

孤街醉人 提交于 2019-11-29 06:45:51
Problem How can I avoid the following error from Lua 5.1 when attempting to do a circular require? $ lua main.lua lua: ./bar.lua:1: loop or previous error loading module 'foo' stack traceback: [C]: in function 'require' ./bar.lua:1: in main chunk [C]: in function 'require' ./foo.lua:1: in main chunk [C]: in function 'require' main.lua:1: in main chunk [C]: ? File Structure main.lua require "foo" require "bar" print (Foo.getName()) print (Bar.getName()) foo.lua require 'bar' Foo = {} Foo.name = 'foo' function Foo:getName() return Foo.name .. Bar.name end bar.lua require 'foo' Bar = {} Bar.name

Are circular dependencies considered bad design?

老子叫甜甜 提交于 2019-11-29 04:39:20
In my work (which is 90% Java but I'm sure this question applies to other languages) I often create two classes that "know about" each other. More concretely, class A imports B, and class B imports class A, and both have member or local variables of the other type. Is this considered bad design? An anti-pattern if you will? Here is my take: If the two classes belong to the same logical module, then it's probably fine (still a judgement call of course, with lots of grey areas). It's less fine if the two classes belong to different modules. This creates a circular dependency between modules. I