Skip to content

Latest commit

 

History

History

composite

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

composite

AKA. Object Tree

use a tree structure to manage the code

recursion and iteration is important in the implementation

Pros and Cons

Pros:

  • work with complex tree structures more conveniently: use polymorphism and recursion to your advantage
  • introduce new element types into the app without breaking the existing code, which now works with the object tree
    • Open/Closed Principle

Cons:

  • might be difficult to provide a common interface for classes whose functionality differs too much
    • in certain scenarios, you'd need to overgeneralize the component interface, making it harder to comprehend