Composite template with bi-directional linkage between component and composite

I have the problem mentioned in the title of this post. By default, the Composite Pattern has an explicit implementation of the Composite → Component association. But I also need to implement backward merging: Component -> Composite.

enter image description here

In short, what's the best solution for bi-directional communication between a component and a composite object in a composite template?

+3


source to share


1 answer


You only need communication between the component and itself, and call this "parent"

With this construct, all sheets and composites will have a reference to its parent, which means Composite -> Component association



enter image description here

+2


source







All Articles