cyclic-dependency

Guice inject single instance into multiple objects without using @Singleton

流过昼夜 提交于 2019-12-01 06:44:29
I was reading the Guice documentation, and came across a section labeled Eliminate the Cycle (Recommended) which peaked my interest because it's exactly the issue that led me to the documentation today. Basically, to eliminate cyclic dependencies, you "extract the Dependency Case into a separate class." Okay, nothing new there. So, in the example, we have. public class Store { private final Boss boss; private final CustomerLine line; //... @Inject public Store(Boss boss, CustomerLine line) { this.boss = boss; this.line = line; //... } public void incomingCustomer(Customer customer) { line.add

Guice inject single instance into multiple objects without using @Singleton

戏子无情 提交于 2019-12-01 04:11:29
问题 I was reading the Guice documentation, and came across a section labeled Eliminate the Cycle (Recommended) which peaked my interest because it's exactly the issue that led me to the documentation today. Basically, to eliminate cyclic dependencies, you "extract the Dependency Case into a separate class." Okay, nothing new there. So, in the example, we have. public class Store { private final Boss boss; private final CustomerLine line; //... @Inject public Store(Boss boss, CustomerLine line) {

Registering packages in Go without cyclic dependency

Deadly 提交于 2019-11-27 19:25:47
I have a central package that provides several interfaces that other packages are dependent on (let us call one Client ). Those other packages, provide several implementations of those first interfaces ( UDPClient , TCPClient ). I instantiate a Client by calling NewClient in the central package, and it selects and invokes the appropriate client implementation from one of the dependent packages. This falls apart when I want to tell the central package about those other packages, so it knows what clients it can create. Those dependent client implementations also import the central package,

Registering packages in Go without cyclic dependency

笑着哭i 提交于 2019-11-27 04:22:20
问题 I have a central package that provides several interfaces that other packages are dependent on (let us call one Client ). Those other packages, provide several implementations of those first interfaces ( UDPClient , TCPClient ). I instantiate a Client by calling NewClient in the central package, and it selects and invokes the appropriate client implementation from one of the dependent packages. This falls apart when I want to tell the central package about those other packages, so it knows

How to deal with cyclic dependencies in Node.js

安稳与你 提交于 2019-11-26 05:40:43
问题 I\'ve been working with nodejs lately and still getting to grips with the module system so apologies if this is an obvious question. I want code roughly like the following below: a.js (the main file run with node) var ClassB = require(\"./b\"); var ClassA = function() { this.thing = new ClassB(); this.property = 5; } var a = new ClassA(); module.exports = a; b.js var a = require(\"./a\"); var ClassB = function() { } ClassB.prototype.doSomethingLater() { util.log(a.property); } module.exports