S
S. Jacobs
I'm trying to come up with an elegent design to solve this problem and
wondered if anyone had any ideas. Here is the problem:
Object A - parent object
Object B - child object in a many to one relationship with parent
Object B inherits all the properties and values from object A
Object A can change a value to any property and the change should be
inherited from Object B
Object B can change any value of the property inherited from Object A.
The change should NOT be propogated to any siblings or to Object A.
Example:
Object A:
String test = "objectA"
Object B1:
the value of test = "objectA"
Object B2:
the value of test = "objectA"
Action: Object B1 changes the value of test to "objectB"
Result:
The value of A.test is "objectA"
The value of B1.test is "objectB"
The value of B2.test is "objectA"
Action: Object A changes the value of test to "objectAAA"
The user can choose whether to propogate the change to the child
objects. The user chooses Yes, to propogate the objects.
Results:
The value of A.test is "objectAAA"
The value of B1.test is "objectAAA"
The value of B2.test is "objectAAA"
I'm looking for an elegent solution other than the obvious one of
simply creating 3 identicle objects and copying all the data to all
objects. I'm hoping to find one that is efficient in both object
creation and data storage.
Hope this makes sense! Any and all suggestions are welcome
wondered if anyone had any ideas. Here is the problem:
Object A - parent object
Object B - child object in a many to one relationship with parent
Object B inherits all the properties and values from object A
Object A can change a value to any property and the change should be
inherited from Object B
Object B can change any value of the property inherited from Object A.
The change should NOT be propogated to any siblings or to Object A.
Example:
Object A:
String test = "objectA"
Object B1:
the value of test = "objectA"
Object B2:
the value of test = "objectA"
Action: Object B1 changes the value of test to "objectB"
Result:
The value of A.test is "objectA"
The value of B1.test is "objectB"
The value of B2.test is "objectA"
Action: Object A changes the value of test to "objectAAA"
The user can choose whether to propogate the change to the child
objects. The user chooses Yes, to propogate the objects.
Results:
The value of A.test is "objectAAA"
The value of B1.test is "objectAAA"
The value of B2.test is "objectAAA"
I'm looking for an elegent solution other than the obvious one of
simply creating 3 identicle objects and copying all the data to all
objects. I'm hoping to find one that is efficient in both object
creation and data storage.
Hope this makes sense! Any and all suggestions are welcome