Questions tagged [cyclic-reference]

A cyclic reference is established if object A holds a reference to B while B holds a reference to A.

A cyclic reference is established if object A holds a reference to B while B holds a reference to A. This exposes a dynamic problem ("hen-vs-egg"), for instance in a programming language, to create a cyclic reference, A and B must be known prior to establishing their inter-relationship. Thus a form of temporal sequence (delay) is needed if data structures are purely functional, for example by declaring the initialization of the references lazy. Cyclic references can also pose problems to garbage collection which needs to detect that none of two objects involved in a cyclic reference are reachable any more by the rest of the code.

143 questions
2
votes
1 answer

Does assigning an instance of class A to member of class A a cyclic reference?

class Yummie(object): instance = None Yummie.instance = Yummie() Since Yummie.instance is an instance of Yummie and type(Yummie.instance) == Yummie is true, would that be an example of a cyclic reference? Should I prefer to create a weak…
Niklas R
  • 16,299
  • 28
  • 108
  • 203
2
votes
1 answer

Scala type error for cyclically referenced traits

I'm having trouble getting this code to work. I want to make a trait that allows a class that inherits it to have "children", but apparently, Child's setParent method wants a P, but gets a Parent[P, C] instead. package…
bb94
  • 1,294
  • 1
  • 11
  • 24
2
votes
1 answer

C++11, shared_ptr.reset() and cyclic references

I have a question about the behaviour of shared_ptr.reset(). In this scenario I have a cyclic reference with the following classes. I have a book and an owner, which both have std::shared_ptrs to each other, creating a cyclic…
GECH
  • 83
  • 1
  • 8
2
votes
0 answers

build.sbt defining project dependency between modules

I have project in PlayFramework. It has one main project without any code/logic. And it have few submodules: main: admin common shop Modules: admin and shop will base on common module (classes like: user, role, permission), so I have to…
masterdany88
  • 5,041
  • 11
  • 58
  • 132
2
votes
1 answer

Cyclic imports within django subapps

I'm working on a django project where i have the following setup project /products /product1 /models.py /forms.py /productN /otherapps #models.py from .forms import foo ... #forms.py from .models…
SverkerSbrg
  • 503
  • 1
  • 9
  • 23
2
votes
1 answer

Cyclic reference in a database table

I am quite ashamed to ask this, but recently there has been a situation where I need to create a single table for three different types of banking entities that are related to each other. Let me explain. Imagine a BANK table that holds details of…
Dchucks
  • 1,189
  • 5
  • 22
  • 48
2
votes
1 answer

Is cyclical referencing bad practice?

Say I have three classes: EntityManager, Entity, and Component. Entity has an array of components (pointers), and each of these components have a field that is a pointer to the encapsulating Entity. EntityManager has an array of entities, and each…
user2687268
  • 113
  • 1
  • 5
2
votes
1 answer

Compiling C++ many to many class relations

I want to know how to achieve the following design. I have not put effort to follow the standard conventions in order to keep this dummy code to a minimum (eg, include guards). For arguments sake, I am using C++03, and only standard library…
vvnraman
  • 1,322
  • 13
  • 21
2
votes
1 answer

Initialization order of values in objects: How to setup cyclic/recursive objects properly?

The following code abstract class Table(val name: String) { val columns: List[Column] def getAliasColumns: String = { val reallyThere = columns.forall(c => c != null) println("Columns really there: " + reallyThere) if (reallyThere…
2
votes
1 answer

Custom JSON Serialization of object with "self-creating" property ends in infinite loop

In a project(in C#) that I am working on I have to use a JSON representation that also contains methods of serialized object. That is the reason why I have to implement my own serializer. The Serializer is quite simply implemented with reflection.…
JeFf
  • 346
  • 5
  • 16
2
votes
0 answers

Object cloning with cyclic reference chain

I'm running some operations on a graph in memory, which modify the graph itself. I need to repeat these operations some number of times, and subsequent repetitions must work on a fresh copy of the graph. Since the graph is generated by parsing a…
Andy Hunt
  • 1,053
  • 1
  • 11
  • 26
1
vote
0 answers

How to create a many-to-many relationship without CASCADE in Entity Framework 4.1?

I am making an MVC3 web app using Entity Framework 4.1. The problem is that I have a cyclical reference and I get an exception. I understand why it is wrong so I would like to remove ON DELETE/UPDATE CASCADE from my many-to-many relationship. The…
1
vote
1 answer

Dot notation for React components

Let's say I have FieldUpdate and FieldUpdate.Radio component: src > components > fieldUpdate > index.tsx, radio.tsx // index.tsx import React from 'React'; import Radio from './radio'; const FieldUpdate = (props) => ( . . …
nanakondor
  • 615
  • 11
  • 25
1
vote
2 answers

WCF Ria Services and Cyclic references

I'm using a legacy database that has some cyclic references. When I consume my Ria service from a SL4 client. (generated entities through my ORM mapper) I get the following error: There was an error while trying to serialize parameter…
krikke999
  • 33
  • 4
1
vote
3 answers

How to create mutually referencing data structures in Haskell?

I've exploited the fact that when the JVM creates an object (immutable or not), its pointer is created before its fields are initialized. That allows me to create something like this: class BackRefdNode(val…
caeus
  • 3,084
  • 1
  • 22
  • 36