# Composite Pattern

*noun*

say it: **“kum-PAH-zit PAT-urn”** **/kəmˈpɑzɪt ˈpætərn/**

A design pattern where a group answers the same questions as a single item, by asking each of its parts.

## What is the **Composite pattern**?

The **Composite pattern** lets a group of things answer the same questions as a single thing, so code treats one item and a whole group alike. A box and a pallet both answer `weight()`: a box with its own pounds, a pallet by asking each thing on it, other pallets included, however deep they're stacked. No code has to ask "is it a box or a pallet?".

## In a sentence

- “With the **Composite pattern**, a pallet weighs itself by asking each thing on it, so stacking pallets ten deep needs no new code.”

Level: Journeyman · [More OOP terms at this level](https://www.ask-codey.com/glossary?category=oop&level=3)

Updated: November 9, 2026

Source: https://www.ask-codey.com/glossary/composite-pattern
