Design Patterns · Junior · Question 18 of 75

Which pattern lets you treat a tree (a menu with submenus, a file system) uniformly?

Explanation

Composite describes both leaves and containers with one interface, so the client traverses the tree without "is it a folder or a file" checks. The React component tree, the DOM and nested menus are natural examples.

Further reading

Problem with a question

Design Patterns · Junior · question 18

Test yourself

Take the Design Patterns · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz