Questions tagged [self-reference]

Self-reference is the ability of a program (or logical sentence) to refer to itself, either directly or indirectly.

Self-reference is the ability of a program (or logical sentence) to refer to itself, either directly or indirectly.

Useful Links:

Stanford Encyclopedia 'Self Reference' Entry

Related Tags:

596 questions
3
votes
2 answers

Symmetric relationship in EF Code first

I'm not sure if I've got my wording correct (which might be why I'm struggling to find results). Here's what I'm trying to achieve: I'd like to be able to be able to add a collection of related products (Product B, Product C) to Product A. I'd like…
3
votes
0 answers

How to unset an object which contains a self-reference?

I have found this solution, but perhaps there is a better one, what do you think about it? class A { #A self-reference private $_a; #Construcotr makes a self-reference public function __construct() { …
3
votes
1 answer

Is there a better way to self reference a type?

I'm finding lately a lot of code smells related to referencing generic classes in C#. My gripes especially apply to those classes which inherit from DependencyObject and contain DependencyProperties. The basic problem is that when declaring a…
jpierson
  • 16,435
  • 14
  • 105
  • 149
3
votes
1 answer

Javascript: Define variable as anonymous function that calls the same function

I am given a function like this: //! Work on record. /*! \param[in] Record (object) Record. \param[in] AsyncCallback (function) Asynchronous callback which is called when the operation is complete. It takes no…
3
votes
2 answers

SQL Server 2008 Delete Records from Self-Referencing Table in correct order

Possible Duplicate: SQL: DELETE data from self-referencing table in specific order I need to delete a sub set of records from a self-referencing table in SQL Server 2008. I am trying to do the following but it is does not like the order by. WITH…
KTrace
  • 486
  • 1
  • 5
  • 12
3
votes
2 answers

SQL self-referencing query. JOIN

i need to query a self referencing relationship for unit prerequisites. i know that you need to use two Joins, do i SELECT my column and then join it to itself ? SELECT u.unit_code, u.name + ' is a prerequisite of ' + u.name AS…
LewisFletch
  • 125
  • 3
  • 6
  • 16
3
votes
2 answers

How would you model contact list with self-reference and category?

Wrestling my head to model following User has many Contact categories (family/friends) One Contact category has many contacts One contact can be in one or more contact categories. I end up with following, but I still believe, there must be better…
Jakub Kuchar
  • 1,665
  • 2
  • 23
  • 39
3
votes
2 answers

PHP - clone an object that contains references to itself?

What is the best way to create a clone of a complex PHP object that includes many references to itself, so that the new object's references point to its own methods and properties, not those of the original object? I understand from the manual that…
user56reinstatemonica8
  • 32,576
  • 21
  • 101
  • 125
2
votes
3 answers

Finding the parent object in a self-referencing Java class

I've created a class to mimic a file structure for a program (a text-based game) I'm working on. This is a simplified version: public class Dir { public Dir(String name, Dir[] subdirs) { this.name = name; this.subdirs = subdirs; } …
ArmanX
  • 97
  • 1
  • 9
2
votes
1 answer

I am trying to change follower status from 'requested' to 'approved' in relationship model

I have a relationship table with followed_id, follower_id, and status. I am using "has many through" in my user model to create the association. A user has many following through and is following many through a reverse relationship. The status…
2
votes
5 answers

Is it possible to emulate object methods in C?

Is it possible to emulate object methods in C? I'd like to be able self-reference a structure as a parameter to a member function argument e.g.: struct foo { int a; int (*save)(struct foo *); }; int save_foo(struct foo *bar) { // do…
ben lemasurier
  • 2,582
  • 4
  • 22
  • 37
2
votes
2 answers

Many to Many (self related) specific order entity framework

Hello I'm trying to do the impossible apparently. I need a self referenced table with a many to many relationship to itself that also has a specific order in c# entity framework (4.2) database first. Think of it like Friends having Friends in…
psy
  • 2,791
  • 26
  • 26
2
votes
3 answers

Analog of 'arguments.callee' in Lua

Is there a way to refer to the currently executing anonymous function in Lua? Just like we can do in JavaScript with arguments.callee. E.g.: local function newLiftAnimator(obj) local count = 0 return function(event) -- animate obj's…
Vitaly
  • 4,358
  • 7
  • 47
  • 59
2
votes
1 answer

SQL Server - Checking for integer (id) within hierarchy of ids

How would one go about checking whether a given ID is within a hierarchy of IDs? For example, let's say I have the following hierarchies in a self-referencing table called locations (e.g. these are hierarchical locations): -- Declare the locations…
rlarson
  • 75
  • 6
2
votes
1 answer

How do I draw reflexive association if there are inheritance

My teacher gave us a homework to draw a class diagram using something like this class PersonRole{} class Employee{ isA PersonRole; } class Manager { isA Employee; 0..1 -- * Employee; } I know in order to draw a reflexive association, both…
AmazingEgg
  • 23
  • 2