@@ -120,6 +120,23 @@ trasparente per il client. Questo è un classico caso di compromesso. A volte fa
120120che sembra violare il principio. In alcuni casi, tuttavia, questa è una questione di prospettiva; per esempio, potrebbe
121121sembrare sbagliato avere operazioni di gestione figli nei nodi foglia (come _ add()_ , _ remove()_ e _ getChild()_ ), ma poi
122122puoi sempre cambiare prospettiva e vedere una foglia come un nodo con zero figli.
123+
124+ Composite pattern allows you to compose objects in tree structures to represent entire hierarchies. Composite pattern
125+ allows clients to treat single objects and object compositions uniformly. Using a structure
126+ composite, we can apply the same operations to both composite data and individual objects. In other words, in the
127+ most of the cases we can ignore the differences between the compositions of objects and individual objects. With this
128+ pattern it seems that the principle of single responsibility is violated as a class that implements it is found
129+ to do two things, manage a hierarchy and manage operations on the end nodes (the leaves of the tree). We can however
130+ to say that the Composite pattern takes the design of the SRP and mistakes it for _ transparency_ ; allowing the interface
131+ Component to contain child management operations and leaf operations, a client can treat both uniformly
132+ the composite data that the leaf nodes; therefore, if an element is a composite or leaf node it becomes transparent to the client.
133+ By allowing the Component interface to contain child management operations and leaf operations, a client can
134+ treat both composites and leaf nodes uniformly; so if an element is a composite or leaf node it becomes
135+ transparent to the client. This is a classic case of compromise. Sometimes we intentionally do things one way
136+ which seems to violate the principle. In some cases, however, this is a matter of perspective; for example, it might
137+ seem wrong to have child management operations in leaf nodes (like _ add () _ , _ remove () _ and _ getChild () _ ), but then
138+ you can always change perspective and see a leaf as a node with zero children.
139+
123140```
124141php src/Composite/Menu/client.php
125142```
0 commit comments