Questions tagged [circular-reference]

A circular reference is a series of references where the last object references the first, resulting in a closed loop.

A circular reference is a series of references where the last object references the first, resulting in a closed loop.

Circular references can appear in computer programming when one piece of code requires the result from another, but that code needs the result from the first.

Information is taken from Wikipedia, more information available there.

758 questions
6
votes
1 answer

Endless loop in a code sample on serialization

Have a look at the following code from here. It's about preserving circular references in a datacontract (object model, object graph, domain model) when serializing in wcf. class ReferencePreservingDataContractSerializerOperationBehavior …
Gerard
  • 13,023
  • 14
  • 72
  • 125
6
votes
2 answers

Dynamically creating graphql schema with circular references

By using graphql-js, I need to create graphql schema dynamically by iterating over array of some data, for example: [{ name: 'author', fields: [{ field: 'name' }, { field: 'books', reference: 'book' }] }, { …
6
votes
3 answers

Event circularity

I find myself quite often in the following situation: I have a user control which is bound to some data. Whenever the control is updated, the underlying data is updated. Whenever the underlying data is updated, the control is updated. So it's…
digital_fate
  • 567
  • 1
  • 5
  • 15
6
votes
1 answer

Randomness in Spring Bean creation when there is circular bean dependency

Our application uses extensively uses Spring Beans, we randomly see application startup error saying that there is Circular Bean Dependency. But this error doesn't occur always, but is instead random across multiple restarts. What could be the…
6
votes
4 answers

Are circular references ever necessary?

I've inherited a Visual Studio Solution that contains numerous circular references between Projects. Is there ever a situation where this is remotely acceptable? Just trying to confirm my suspicion that this application is designed horribly. Thanks…
John B
  • 20,062
  • 35
  • 120
  • 170
6
votes
2 answers

Finding circular references within PostgreSQL table?

I have one table with attributes (ID int, SourceID int, TargetID int, TargetType int) ID SourceID TargetID --------------------- 1 123 456 2 456 789 3 1 123 4 456 1 5 2 1 I want to find…
6
votes
2 answers

How to use circular references in RestKit using $ref and $id

I have an API using the json.net serialization library. It uses $ref and $id fields for circular references. RestKit does not realize that these $ref fields are referring back to another object that has already been serialized. Is there a way to…
Kyle Redfearn
  • 2,172
  • 16
  • 34
6
votes
2 answers

POJO with other POJO references

I am working on a API to access data stored in a system. The system contains things like people, appointments and procedures associated with those appointments. My application will strictly be read-only. I am using Spring w/ RowMapper to build…
jr.
  • 4,503
  • 7
  • 44
  • 62
6
votes
2 answers

How to initialize const circular reference members

For example, I have two classes class Foo; class Bar; class Foo { const Bar &m_bar; ... }; class Bar { const Foo &m_foo; ... }; Let foo is object of Foo and bar is object of Bar. Is there any way (normal or "hacking") to create/initialize…
6
votes
6 answers

Django AttributeError: 'str' object has no attribute '_default_manager'

The following error seems to occur randomly on my live server (i.e. through apache mod_wsgi) but never in development (i.e. localhost python manage.py runserver). Note this happens infrequently and is not something that can be reproduced easily or…
chewynougat
  • 1,099
  • 2
  • 11
  • 19
6
votes
4 answers

Reason for circular references with classes?

I'm aware of circular references (Class A holds Class B and Class B holds Class A). But since I haven't programmed enough, it's hard for me to find reasons to use them. I was wondering if people could give me some examples and explain good reasons…
dtc
  • 1,774
  • 2
  • 21
  • 44
6
votes
2 answers

Python Delegate Pattern - How to avoid circular reference?

I would to ask if using the Delegate Pattern in Python would lead to circular references and if so, what would be the best way to implement it to ensure the object and its delegate will be garbage collected? In Objective C, the above problem is…
lightalchemist
  • 10,031
  • 4
  • 47
  • 55
5
votes
1 answer

WcfTestClient.exe not able to handle circular reference?

I'm working on a wcf project. Some of my services return objects that contain circular references. The serialization of these objects is handled through setting IsReference to true on DataContract attribute, so everything works fine if i write code…
weidi
  • 852
  • 7
  • 20
5
votes
4 answers

Why does my lambda get illegal forward reference, but my anonymous class does not?

I am trying to represent a State Transition Diagram, and I want to do this with a Java enum. I am well aware that there are many other ways to accomplish this with Map or maybe with a static initialization block in my enum. However, I am…
davidalayachew
  • 1,279
  • 1
  • 11
  • 22
5
votes
2 answers

Python: Circular dependency of dataclasses / Forward variable declaration?

So, I have these two dataclasses in a file: @dataclass class A: children: List[B] @dataclass class B: parent: A , which are possible with the use of the __future__.annotations feature. Then I have two other files, each with a bunch of…