0

This is a confusing question to word. Let's say I have a class, Fruit, which has fields Color, Name, etc. (simplified example) If I have a Color (let's say it's a whole class not a primitive) is there a term for the Color's association to Fruit as the "color" field? The application for this use is more of a Java wrapper around a JSON object. Given an instance of a property within a JSON hierarchy I want to add a custom metadata field that contains the name of the field within its parent that it resides within. e.g. I want the Color class to have a field that is populated with the name of the field name it is within in the containing Fruit class.

Is there a term for this association? The child's parent's field name that represents this child? I'm trying to name a variable and "parentFieldNameForThisChild" is stupid and long and I feel like there must be a formal name for this.

To clarify, the parent object is not what I am after. If the Fruit class looks like this:

class Fruit {
    Color fruitColor;
    String fruitName;
}

If I am a Color object I want to know that I am contained within the "fruitColor" property of my parent, the Fruit class. This is the association I am looking for a term for. Again, this is a simplified example, and will be applied to a JSON wrapper where the property name is not known explicitly in the code and must be retrieved from the JSON structure.

john
  • 1
  • 1
  • What happens if you add a `Color` field to a `Car` type? – Sotirios Delimanolis Feb 17 '15 at 21:52
  • Same concept. The stored value would be whatever the Color member property is named within the Car type. The name of said association is what I am after (i.e. what do I call this value?) – john Feb 17 '15 at 22:43
  • Am I overthinking this? I don't want to just use "fieldName" even though that is probably the most correct because it's also too vague for my liking. "parentFieldName" is misleading. "nameOfThisObjectsFieldWithinItsParent" is way too long. There must be a formal name for this association. – john Feb 17 '15 at 22:45

2 Answers2

0

The jquery association is simple parent. http://api.jquery.com/parent/ Because of its hirarchy the access is easy and an additional Field is redundant. Theres is always only one patent, so a type Definition is not necessary. My vote is "parent".

Daniel
  • 795
  • 1
  • 10
  • 25
  • Parent is not the same as what I am looking for. "Parent" in my example would be an instance of the "Fruit" class. What I am looking for is a way to describe the child's property name within the parent class. If I have a class representing the fruit's color and it is stored in the "fruitColor" property within the Fruit class then what I am looking for is "fruitColor", the name of the field containing the child, not the parent object itself. – john Feb 17 '15 at 22:36
0

What you are describing is object composition & aggregation relationship.

In your example, a Fruit has a Color, but a Color can exist on its own (or can it ?) - it really depends on your design. Anyway the relationship is either composition or aggregation.

You may want to have a generic name for the relationship, e.g. association-name and the type of the association in another field, e.g. association-type and why not association-cardinality.

This SO thread or this one can help to understand the different relationships between objects.

You can find some naming ideas in a specification language like Unified Modeling Language, and here in the UML glossary.

Community
  • 1
  • 1
T.Gounelle
  • 5,953
  • 1
  • 22
  • 32
  • The closest appropriate term I could finding looking up some of those links is "is-a", which is not really accurate but is sort of close. The color "is a" fruitColor of the Fruit class. It's more like the color "is THE" fruitColor of the specific Fruit class instance that is its parent. But that is also a weird way to phrase it. – john Feb 17 '15 at 23:01