lundi 30 mars 2020

If a particular component is frequently referenced in a composite pattern, how can it be referenced?

First, sorry for my poor English.

The composite pattern is configured, as shown in the image. EventListener G, H ,I must refer to ComponentC. There are two ways to do this ,that I know.

(1) pass ComponentC's reference through ComponentA - ComponentE (2) declare static reference of ComponentC

but I think, (1) has too much code. because, ComponentC's reference is used for only ComponentE, not D,F

and I think, (2) has risk of wrong access.

then, I'd like to know if there are another ways besides (1) and (2).

I hope the questions are delivered correctly. Thank you for reading it.

enter image description here

Aucun commentaire:

Enregistrer un commentaire