Are there any patterns or is there any standard terminology for inheriting data / objects?

I have a class A that has a collection of objects of class B. Class A can also “inherit” (for lack of a better term) the collection of objects of class B from other instances of class A. To simulate this, instances of class A point to other instances of class A (I manage circular references).

A simplified case study may be that a person has biological children, but also “inherits” children from their spouse and former spouses.

I use class A instances with and without inherited objects in my application at runtime. That is, both “projections” of class A instances make sense to me in the context of my application in difference scenarios.

My question is: is there a sample for coding such a model or standard terminology? I don’t think that “inherit” is the right word here. I have my own ways of processing it technically and my own cumbersome terminology, but I imagine that there is a standard pattern that I can stick to, which I simply can not find.

The failed analog will test .NET class methods with and without their inherited methods, or test prototypes in Javascript, but here I am inheriting records / objects.

+3
source share
4 answers

, , (A) , , (B) - , . (C), . , , , , , . , -, , , . , , "", , . . . , , !

, , - . , inherit above , , 100%. ?

ClassA ClassB. , ClassA ClassB, , ClassA. ClassA ClassA .

, , , . , , . , , -, , , , - .

+1

, A B. A, A, . , , , .

+2

, . , , , - , . - "" ( -). , .

0

:

  • A - B
  • A B

:

  • A B
  • B A
  • A ( ) B

The first two are similar, but your specific example clearly refers to the third. Parents do not support children, they are associated with their children, and when someone marries a family, they have new relationships (associations) created with an existing family.

So, I think the answer is no, there is no "pattern". You simply copy / transform a set of relationships from one instance to another.

0
source

Source: https://habr.com/ru/post/1727957/


All Articles