the composite pattern the composite pattern allows complex tree-like structures to be built from simple components these componentscalled composite objectsare able to behave sort of like container and sort of like variable depending on whether they have child components composite objects are container objectswhere the content may actually be another composite object traditionallyeach component in composite object must be either leaf node (that cannot contain other objectsor composite node the key is that both composite and leaf nodes can have the same interface the uml diagram is very simplecomponent +some_action(leaf composite +some_action(+some_action(+add_child(this simple patternhoweverallows us to create complex arrangements of elementsall of which satisfy the interface of the component object here is concrete instance of such complicated arrangementcomposite leaf leaf leaf composite composite leaf leaf leaf leaf composite leaf leaf composite leaf the composite pattern is commonly useful in file/folder-like trees regardless of whether node in the tree is normal file or folderit is still subject to operations such as movingcopyingor deleting the node we can create component interface that supports these operationsand then use composite object to represent foldersand leaf nodes to represent normal files