Summary
In this chapter, we’ve looked at how structural design patterns enable the extension of functionality without needing to rework interfaces in JavaScript.
The proxy design pattern is useful when we want to intercept calls to an object without changing the interface.
By contrast, the decorator design pattern concerns itself with dynamically adding functionality through new instance members.
The flyweight pattern can be used effectively for managing large numbers of objects, which is especially useful for value objects. There are workarounds in JavaScript for some of the ergonomic drawbacks of it.
The adapter pattern allows us to integrate multiple classes, modules, or functions with different opinions and interfaces without modifying them. The shape of the adapter is dictated by the existing modules and classes that we’re attempting to connect together.
Now that we know how to organize relationships between different objects and classes with structural...