{"id":4775,"date":"2014-03-30T15:18:59","date_gmt":"2014-03-30T15:18:59","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/problem-about-circular-dependency-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:42:27","modified_gmt":"2022-08-30T15:42:27","slug":"problem-about-circular-dependency-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/problem-about-circular-dependency-collection-of-common-programming-errors\/","title":{"rendered":"problem about circular-dependency-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/196439db37b40bbd20479e11606b78d2?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nqehgt<br \/>\n.net f# abstract-class circular-dependency circular-reference<br \/>\nConsider the two abstract classes alpha and beta:[&lt;AbstractClass&gt;] type alpha () =abstract member foo: beta-&gt;beta[&lt;AbstractClass&gt;] and beta () = \/\/***abstract member bar: alphaIf I try to compile that I get an error, on the line indicated with * * *:error FS0010: Unexpected keyword &#8216;and&#8217; in interactionAnd if I write:[&lt;AbstractClass&gt;] type alpha () =abstract member foo: beta-&gt;betaand beta () =abstract member bar: alphathen I get:error FS0365: No implementation was giv<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/0c165565955c2f424ee85510d0aedb4d?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nmeh<br \/>\nc++ circular-dependency<br \/>\nwhat i want to do is when A object enters a new class K it has to exit(deleted from the lists) all of the K(child B and D)s it is in but i get this error just cant figure it out. there is actually a bigger list that lists class K s but i cant reach it by reference(well i can but lots of work not the point)and project has to be circularly dependent \/\/class A.h #include some_other_header_circularly_dependent_on_class_B class B class A{ public:string getname(){return name;};void setWhere(K *a){wher<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/c2b2f5defc2ecc537b245919ea6dc4b4?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nM.ES<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/7dcf183534c94987870537b0d87914e1?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nwrongusername<br \/>\npython import python-3.x circular-dependency<br \/>\nSay I have three files like this:testimports module:#import moduleTwo import moduleOnehiString = &#8220;Hi!&#8221;moduleOne.sayHi()moduleOne:import moduleTwoclass sayHi():moduleTwo.printHi()moduleTwo:import testimportsdef printHi():print(testimports.hiString)If I run testimports, I get the following:Traceback (most recent call last):File &#8220;..file path snipped..\/testimports\/src\/testimports.py&#8221;, line 2, in &lt;module&gt;import moduleOneFile &#8220;..file path snipped..\/testimports\/src\/moduleOne.py&#8221;, line 1, in &lt;m<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/2bfafb4d16a6dc78abef970bcab9ca97?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nmikera<br \/>\nclojure source-code circular-dependency<br \/>\nI&#8217;m working on some Clojure code that has some circular dependencies between different namespaces and I&#8217;m trying to work out the best way of resolving them.Basic issue is that I get a &#8220;No such var: namepace\/functionname&#8221; error in one of the files I tried to &#8220;declare&#8221; the function but then it complains with: &#8220;Can&#8217;t refer to a qualified var that doesn&#8217;t exist&#8221; I could of course refactor the entire codebase but that seems impractical to do every time you have a dependency to resolve&#8230;.. and might<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/e2d3b3b07dc7cce8f940b83f4c51bf8e?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nmicahtan<br \/>\nc# dependency-injection assemblies circular-dependency<br \/>\nProject#1 has some interfaces and classes that project#2 references.Now I want to use the implementation of Project#2 in Project#1 but vs.net complains about a circular dependency.If I was to use dependancy injection in Project#1 and bind to the implementation in Project#2 (since it adheres to the interface contract), will this work or I will still get the circular dependency error message at runtime?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/5fbed9fdc4a20ca4bbaa2701fe21ffa6?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nsuat<br \/>\nmaven circular-dependency cyclic<br \/>\nThis gives me headache&#8230;I have a project called &#8216;talktome&#8217;, with no runtime dependencies.Also I have project &#8216;talktome-tools&#8217;, which depends on &#8216;talktome&#8217;.No problems, until I realize that the unit-tests in &#8216;talktome&#8217; depends on &#8216;talktome-tools&#8217;.What solutions are there?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/PZnlu.png?s=32&amp;g=1\" \/><br \/>\nDukeling<br \/>\nc++ static include circular-dependency<br \/>\nIn a project I have 2 classes:\/\/ mainw.h#include &#8220;IFr.h&#8221; &#8230; class mainw { public: static IFr ifr; static CSize=100; &#8230; };\/\/ IFr.h#include &#8220;mainw.h&#8221; &#8230; class IFr { public float[mainw::CSize]; };But I cannot compile this code, getting an error at the static IFr ifr; line. Is this kind of cross-inclusion prohibited?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/094c4877f215aa468d84c42a4127c585?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\ngimpf<br \/>\nc# circular-dependency<br \/>\nI have the following situation:1) A project MyCompany.MyProject.Domain which contains my domain model, and partial classes (such as Contact).2) I want to &#8216;extend&#8217; (by partial class, not extension method) my Contact class with a property &#8220;Slug&#8221; which will give me a simple URL friendly text representation of first and last name.3) I have a string extension method ToSlug() in my &#8216;Utility&#8217; project MyCompany.MyProject.Utilities which does exactly what I want in 2).4) The problem: My Utility project i<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/ec198cb6fc38d98bb88dd390e0bed8e3?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nOliver Salzburg<br \/>\nc# circular-dependency<br \/>\nIn my project I have two libraries that would currently result in a circular dependency which I am unable to resolve.One library provides common data structures for the whole solution. This library contains a construct similar to this:namespace Common {public class Foo {\/\/[Editor( typeof( UserEditor ), typeof( UITypeEditor ) )]public UInt32 OwnerId { get; set; }}public class User {public UInt32 Id { get; set; }} }Now in one of the projects in our solution, we would like to edit Foo instances thr<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/2807e279ada3bb19bad41a54af66114d?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nNick<br \/>\ndependency-injection cdi circular-dependency jboss-weld<br \/>\nI&#8217;m running into a issue with CDI Injection into a Weld container in JBoss 7.1.1I&#8217;ve got the following object model :@Stateless class ServiceEjb { @Inject A a; }class A { @Inject B b; }class B { @Inject A a; }When trying to inject A or B in my stateless class, injection loop and crash with a javax.enterprise.inject.CreationException.I try many thing (scoping, @Singleton on A or B but without success). I don&#8217;t want to break the code, and those injections makes senses.Any clues will be greatly app<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/471b3ac93ac8da3a68c8dd72c9225fcd?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nF.C.<br \/>\npython oop class variables circular-dependency<br \/>\nPython won&#8217;t allow me to import classes into eachother. I know there is no &#8220;package&#8221; solution in Python, so I&#8217;m not sure how this could be done. Take a look at my files&#8217; codes:file Main.py:from Tile import tile tile.assign() class main:x = 0@staticmethoddef assign():tile.x = 20file Tile.py:from Main import main main.assign() class tile:x = 0@staticmethoddef assign():main.x = 20I get the error &#8220;class tile can not be imported&#8221;.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/1d8f6a3776d0478e3d63760e36962086?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\npedrosanta<br \/>\nc++ class architecture circular-dependency<br \/>\nI&#8217;m gonna go C++ \u00fcber n00b on this one and ask how is the best way to deal with a circular dependency when you have inheritance.The set is simple: Scene class extends Actor; Scene has a pointer to a vector of Actors; Actor has a pointer for (parent) Scene.As for include files I got:Scene.h:#include &lt;string&gt; #include &lt;vector&gt; using namespace std;#ifndef __Scene_h__ #define __Scene_h__#include &#8220;Actor.h&#8221;namespace myns {\/\/ class Actor;class Scene; }namespace myns {class Scene: public myn<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/bd5c864fec9209546b3da1cf717193b0?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nicedwater<br \/>\njavascript coffeescript requirejs circular-dependency<br \/>\nI believe all four methods below will work, but it&#8217;s unclear to me why anyone would ever use the first three simply because it&#8217;s more code. However, the first (and most verbose) one is the one given in the RequireJS docs.define &#8220;circular1&#8221;, [&#8220;example1&#8221;], -&gt; &#8220;circular1&#8221; define &#8220;circular2&#8221;, [&#8220;example2&#8221;], -&gt; &#8220;circular2&#8221; define &#8220;circular3&#8221;, [&#8220;example3&#8221;], -&gt; &#8220;circular3&#8221; define &#8220;circular4&#8221;, [&#8220;example4&#8221;], -&gt; &#8220;circular4&#8243;#1 define &#8220;example1&#8221;, [&#8220;require&#8221;, &#8220;circular1&#8221;], (require, circular) -&gt;<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/054dba7842330d7a9ae87d4773847d12?s=128&amp;d=identicon&amp;r=PG\" \/><br \/>\npiokuc<br \/>\nc++ circular-dependency<br \/>\nI&#8217;m having a problem with circular dependencies, I suppose this is a design flaw from introducing the Game class in the wrong way.Game.h:#pragma once #include &lt;SFML\\Graphics.hpp&gt;#include &#8220;GameScreen.h&#8221; #include &#8220;TitleScreen.h&#8221;class Game { protected:sf::RenderWindow window;GameScreen* CurrentGameScreen;TitleScreen Title;public:Game(void);~Game(void);sf::RenderWindow getWindow(void);void Run();void Close(); };GameScreen.h:#pragma once#include &#8220;Game.h&#8221;class GameScreen { public:GameScreen(void<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/6c42283aeb1521ae0e27bd41b7fdb227?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nAnthony<br \/>\nc++ compiler-errors circular-dependency<br \/>\nI have three classes: a TopClass which contains an instance of a BottomClass pointer. The BottomClass contains a pointer to a HelperClass. The HelperClass keeps a pointer to the TopClass. Circular dependency pops up and a forward declaration is needed in the HelperClass.All of this is illustrated with the following code snippets:#include &#8220;BottomLevel.h&#8221;namespace foo {class TopLevel{private:BottomLevel* item;}; }-#include &#8220;HelperClass.h&#8221;namespace foo {class BottomLevel{private:HelperClass* item;}<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/ffeccc0bf6020a4c7cfb2f014e02de35?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nGili<br \/>\nc++ templates circular-dependency<br \/>\nBackground: I am working on a framework that generates C++ code based on an existing Java class model. For this reason I cannot change the circular dependency mentioned below.Given:A Parent-Child class relationship Parent contains a list of Children Users must be able to look up the list element type at run-timeI&#8217;ve modeled this in the following testcase:Main.cpp#include &#8220;Parent.h&#8221;#include &lt;iostream&gt; using std::cout; using std::endl;int main(int argc, char* argv[]) {Parent parent;cout &lt;<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/26152850470c19aadf14c0e588cd3eb9?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nRia<br \/>\nc++ pointers struct circular-dependency<br \/>\nI have many interdependent array of structures. Im struggling hard with member variable pointers to a record in array of another struct. Putting 3 structs for your referencestruct struct1 { int node_id; struct2* ptr; };struct struct2 { int node_id; int type; struct1* owner; struct2* next; struct2* previous; struct3* block1; struct3* block2; };struct struct3 { int node_id; int n_entries; struct3* next_block; };now my question is how can I fetch records for struct1. I knew that it can be asstruct<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/fb02d7afb172dbbfcf0e5d9829b544f0?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nOmarOthman<br \/>\nc++ compiler-errors circular-dependency<br \/>\nI often find myself in a situation where I am facing multiple compilation\/linker errors in a C++ project due to some bad design decisions (made by someone else \ud83d\ude42 ) which lead to circular dependencies between C++ classes in different header files (can happen also in the same file). But fortunately(?) this doesn&#8217;t happen often enough for me to remember the solution to this problem for the next time it happens again. So for the purposes of easy recall in the future I am going to post a representat<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/b072fc2897196b3bafcd337bc9c91e2d?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nopensas<br \/>\njavascript inheritance prototypejs requirejs circular-dependency<br \/>\nI&#8217;d like to get something like thisvar isChild = isInstanceOf( var1, &#8216;Constructor&#8217;)that should be equivalent tovar isChild = (var1 instanceof Constructor)The thing is I do not have the function Constructor available in scope, so I&#8217;d like to just pass a string.I guess I should traverse up the prototype chain in order to get the constructor.toString() and then compare it, but I don&#8217;t quite know how to achieve it.&#8211; I will complete a little bit the context, mainly because I found a better solutionI<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/2385676760fc16f76a43f3319faaa843?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJohannes Schaub &#8211; litb<br \/>\nc++ templates inheritance circular-dependency incomplete-type<br \/>\nin this code, compiler complain about undefined MyClassB, which is understandable :class MyClassA; class MyClassB;template &lt;class T&gt; class BaseClass : public T { };class MyClassA : public BaseClass&lt;MyClassB&gt; { };class MyClassB : public BaseClass&lt;MyClassA&gt; { };but in this code, compile is successful and no complain about MyClassB :class MyClassA; class MyClassB;template &lt;class T&gt; class BaseClass : public T { };class MyClassA : public BaseClass&lt;std::vector&lt;MyClassB&gt;<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/c516cc5088c9e21546753ac64c830c84?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nbughi<br \/>\nc++ circular-dependency<br \/>\nI came across the following code in an articlestruct entire_program {struct B;struct A{B *bbb;void Aa() { B bb; bb.Bb(); };};struct B{A aaa;void Bb() { A aa; aa.Aa(); };}; };Why am I allowed to call method Bb() in this case, but if I change struct entire_program to namespace entire_program it generates a compiler error?I already read this question, what I am asking is: if it is possible to call methods that are undefined yet within classes\/structs\/unions why don&#8217;t namespaces work the same way<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/f1b6f236a212eae74651cae55a6fddb9?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nPatrick M<br \/>\njavascript scope variable-scope circular-dependency<br \/>\nI have a javascript app that I&#8217;m developing where I&#8217;m building an action tree on the fly and I&#8217;ve found myself in the curious situation of wanting to purposefully introduce a circular dependency. After an initial very hacky attempt, I discovered that JavaScript variable scoping actually introduces a a pretty reasonable way to solve this. I&#8217;m still no expert at JavaScript, so I wanted to get some input on best practices. Here is a snippet of working code:var Step = function(title, instructions, a<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/3cb94b0bde789260845a8f80e8fec52b?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nfencliff<br \/>\njavascript jquery backbone.js requirejs circular-dependency<br \/>\nI&#8217;m setting up a nested categories structure in Backbone with RequireJS.In this structure, a categories collection contains category models, and a single category model can contain a categories collection. Unfortunately this seems to cause the dreaded circular dependencies problem in RequireJS. I have read the docs on RequireJS (http:\/\/requirejs.org\/docs\/api.html#circular) however I am finding the explanation with &#8216;a&#8217; and &#8216;b&#8217; confusing.Here is my code, which is causing the problem:define([&#8220;jqu<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/e689265ee24e0874ae8a90827c4783e7?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nMatrixFrog<br \/>\njavascript json firefox-addon circular-dependency<br \/>\nI have an object that contains circular references, and I would like to look at the JSON representation of it. For example, if I build this object:var myObject = {member:{}}; myObject.member.child = {}; myObject.member.child.parent = myObject.member;and try to callJSON.stringify(myObject);I get the error &#8220;too much recursion&#8221;, not surprisingly. The &#8220;child&#8221; object has a reference to its &#8220;parent&#8221; and the parent has a reference to its child. The JSON representation does not have to be perfectly accu<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/ef852b4f145cf08b2026ae88d2a6d8dc?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nRegexident<br \/>\nc++ shared-ptr circular-dependency<br \/>\nI had faced a circular dependency in my program and solved it with using pointers and forward declarations. I had made a file dn.hpp for this purpose. Everything was OK until I moved to shared pointers instead of generic. I created typedefs for shared pointers in dn.hpp. Everything works with generic pointers (commented out), bun not with shared.It returns an error: field &#8216;parentGraph&#8217; has incomplete type node.h line 21(I am using mingw with boost 1.47)Please help me to resolve this issue.Here<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/5dc3d1e5f2b7676837fdd1fb34b1db15?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJohn Gietzen<br \/>\nf# circular-dependency<br \/>\nI&#8217;m working on IronJS, and one of our source files is getting very long.Right now, I&#8217;m trying to get .NET interop working. I&#8217;m adding the TryBinaryOperation method to the Undefined so that C# can use the JavaScript semantics of the Undefined value.However, this introduces a dependency on the Operators type, which causes a circular dependency.Runtime.fs:type BoxedValue() =struct\/\/ Contains IsUndefined and get_Undefined, referencing the Undefined class, below&#8230;.and type Undefined() =inherit Dyna<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/dbf47288de8dd866eb4ec1c9e126afef?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\njustin<br \/>\nios xcode class forward-declaration circular-dependency<br \/>\nI have a question about the following error &#8220;Unknown type name VistaDereIzq&#8221;I have a view called VistaDereIzq. And I do the following to add that view in this view#import &lt;UIKit\/UIKit.h&gt; #import &lt;MessageUI\/MessageUI.h&gt; #import &#8220;VistaDereIzq.h&#8221; #import &#8220;ViewController.h&#8221;@interface VistaNavegador : UIViewController &lt;UIWebViewDelegate&gt; {VistaDereIzq *VistaIzq2; &lt;&#8212;&#8211; &#8220;Unknown type name VistaDereIzq&#8221;}@end<\/li>\n<\/ul>\n<p>Web site is in building<\/p>\n","protected":false},"excerpt":{"rendered":"<p>qehgt .net f# abstract-class circular-dependency circular-reference Consider the two abstract classes alpha and beta:[&lt;AbstractClass&gt;] type alpha () =abstract member foo: beta-&gt;beta[&lt;AbstractClass&gt;] and beta () = \/\/***abstract member bar: alphaIf I try to compile that I get an error, on the line indicated with * * *:error FS0010: Unexpected keyword &#8216;and&#8217; in interactionAnd if I write:[&lt;AbstractClass&gt;] [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,1],"tags":[],"class_list":["post-4775","post","type-post","status-publish","format-standard","hentry","category-semantic","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4775","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4775"}],"version-history":[{"count":1,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4775\/revisions"}],"predecessor-version":[{"id":8783,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4775\/revisions\/8783"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4775"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4775"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}