language-icon Old Web
English
Sign In

Composite pattern

In software engineering, the composite pattern is a partitioning design pattern. The composite pattern describes a group of objects that is treated the same way as a single instance of the same type of object. The intent of a composite is to 'compose' objects into tree structures to represent part-whole hierarchies. Implementing the composite pattern lets clients treat individual objects and compositions uniformly. In software engineering, the composite pattern is a partitioning design pattern. The composite pattern describes a group of objects that is treated the same way as a single instance of the same type of object. The intent of a composite is to 'compose' objects into tree structures to represent part-whole hierarchies. Implementing the composite pattern lets clients treat individual objects and compositions uniformly. The Compositedesign pattern is one of the twenty-three well-known GoF design patterns that describe how to solve recurring design problems to design flexible and reusable object-oriented software, that is, objects that are easier to implement, change, test, and reuse. What problems can the Composite design pattern solve? When defining (1) Part objects and (2) Whole objects that act as containers for Part objects, clients must treat them separately, which complicates client code. What solution does the Composite design pattern describe? This enables clients to work through the Component interface to treat Leaf and Composite objects uniformly:Leaf objects perform a request directly,and Composite objects forward the request to their child components recursively downwards the tree structure.This makes client classes easier to implement, change, test, and reuse.

[ "Composite number", "Software engineering", "Programming language" ]
Parent Topic
Child Topic
    No Parent Topic