circular-dependency

How can I initialize interdependent final references?

无人久伴 提交于 2020-01-15 07:08:34
问题 I have a class and a factory function that creates new anonymous class objects extending that class. However, the anonymous class objects all have a method in which there are references to other objects. In my full program, I need this to create and combine parsers, but I've stripped down the code here. class Base{ public Base run(){ return null; } static Base factory(final Base n){ return new Base(){ public Base run(){ return n; } }; } } public class CircularReferences{ public static void

MEF error, was circular dependency and is now something else

故事扮演 提交于 2020-01-13 12:06:54
问题 I've got a circular dependency that recently came about because of a change in my application architecture. The application relies on a plugin manager that loads plugins via MEF. Everything up until worked fine, because it looked something like this: // model.cs [Export("Model")] public class Model { public PluginManager PM { get; set; } [ImportingConstructor] public Model( [Import] PluginManager plugin_manager) { PM = plugin_manager; } } // pluginmanager.cs [Export(typeof(PluginManager))]

Forward declaration & circular dependency

痴心易碎 提交于 2020-01-10 14:22:14
问题 I've got two classes, Entity and Level. Both need to access methods of one another. Therefore, using #include, the issue of circular dependencies arises. Therefore to avoid this, I attempted to forward declare Level in Entity.h: class Level { }; However, as Entity needs access to methods in Level, it cannot access such methods, since it does not know they exist. Is there a way to resolve this without re-declaring the majority of Level in Entity? 回答1: A proper forward declaration is simply:

What does it mean and how to fix SonarQube Java issue “Cycles between packages should be removed” (squid:CycleBetweenPackages)

旧时模样 提交于 2020-01-06 02:56:26
问题 Cycles exist between packages when there are dependencies of using or importing kind between classes in these packages. Consider the following example. Let there be 4 classes: Truck and interface Car in org.example.car package and Navigation and CPU in package org.example.part . In packages org.example.car and org.example.part we have use relations between classes Truck --> Car and classes Navigation --> CPU . Let's assume that the class Truck use Navigation class so we have the relationship

Fixing import cycle in Go

被刻印的时光 ゝ 提交于 2020-01-05 03:08:27
问题 So I have this import cycle which I'm trying to solve. I have this following pattern: view/ - view.go action/ - action.go - register.go And the general idea is that actions are performed on a view, and are executed by the view: // view.go type View struct { Name string } // action.go func ChangeName(v *view.View) { v.Name = "new name" } // register.go const Register = map[string]func(v *view.View) { "ChangeName": ChangeName, } And then in view.go we invoke this: func (v *View) doThings() { if

How to Solve Circular Dependency

给你一囗甜甜゛ 提交于 2020-01-04 06:55:07
问题 Hi I have a problem with the structure of my code, it somehow goes into Circular Dependency. Here is an explanation of how my code looks like: I have a ProjectA contains BaseProcessor and BaseProcessor has a reference to a class called Structure in ProjectB . Inside BaseProcessor , there is an instance of Structure as a variable. In projectB there are someother classes such as Pricing , Transaction etc. Every class in ProjectB has a base class called BaseStructure i.e. Structure , Pricing and

Is it possible to load a class without loading referenced classes/imports?

回眸只為那壹抹淺笑 提交于 2020-01-04 04:23:06
问题 (Yes, this is hacky and probably not best practice, but it is the least bulky solution) I have a project that involves several jars - a runnable launcher, a server, a wrapper for the server, and plugins for the server. The launcher runs the wrapper by starting a new unconnected process, a child process, or just by instantiating it, depending on config. This should be unimportant with regards to the issue. The wrapper uses URLClassLoader to load the server jar and start it, which works fine.

Solving circular references for a project that uses both C# and F#

自闭症网瘾萝莉.ら 提交于 2020-01-03 19:40:38
问题 So here's my situation. I have a class library in C#. It exposes some types like Rectangle . It also exposes some methods for doing algorithmic computation. It seemed like a good idea to write those algorithmic bits in F#. So I added another F# library project to the solution. Now here's the issue. In order for the F# project to do algorithmic computations it needs to know about the Rectangle from the C# project. And in order for the C# project to be able to use the F# functions it needs to

Solving circular references for a project that uses both C# and F#

巧了我就是萌 提交于 2020-01-03 19:40:29
问题 So here's my situation. I have a class library in C#. It exposes some types like Rectangle . It also exposes some methods for doing algorithmic computation. It seemed like a good idea to write those algorithmic bits in F#. So I added another F# library project to the solution. Now here's the issue. In order for the F# project to do algorithmic computations it needs to know about the Rectangle from the C# project. And in order for the C# project to be able to use the F# functions it needs to

Dealing with circular inclusion in a parent/child class relationship

一曲冷凌霜 提交于 2020-01-03 15:12:32
问题 Assume I've made a class, say Parent , that has a composition relation with Child . The parent class holds a list of children. I want all children to hold a reference to the parent, so every child holds a Parent pointer. This will cause circular inclusion. I refer to Child in parent.h and I refer to Parent in child.h . Therefore Parent will need to include Child , which needs to include Parent . What's the best way to work around this? 回答1: You'll have to use forward declaration: //parent.h