O'Reilly logo

Pro JavaScript™ Design Patterns by Dustin Diaz, Ross Harmes

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 9The Composite Pattern

The composite is a design pattern that is tailor-made for creating dynamic user interfaces on the Web. Using this pattern, you can initiate complex or recursive behaviors on many objects with a single command. This allows your glue code to be simpler and easier to maintain, while delegating the complex behaviors to the objects.

The composite provides two benefits for you, the overworked JavaScript programmer:

  1. It allows you to treat a collection of objects the same as you would treat any of the particular sub-objects. A composite implements the same operations as its constituent objects. Executing one of these operations on the composite passes it down to all of its children. Each one then executes the same operation. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required