Composite

Learn about a structural design pattern: the composite pattern.

The composite pattern is a structural design pattern.

When to use the composite pattern

There will be parts of our programs that require us to work with objects that are made out of other objects. We have base objects that have a well-defined logic, and then we will have other container objects that will group a bunch of base objects, and the challenge is that we want to treat both of them (the base and container objects) without noticing any differences.

Get hands-on with 1200+ tech skills courses.