In this chapter, we have explored four more structural patterns. As they look quite similar to one another, this chapter opened with a discussion about how to select the proper design pattern for your needs.
The first pattern that was described in this chapter was the adapter pattern. Although it is very similar to the bridge pattern from the previous chapters, it occupies a different niche. Bridge is used to connect two parts of a new design, while the adapter helps us reuse old code in a new environment.
After that, I moved to the proxy pattern. It can appear in many different disguises: protection proxy, remoting proxy, virtual proxy, caching proxy, and more. In all cases, the proxy wraps an interface and then exposes the same interface, possibly by changing the operation of some (or even all) methods of that interface.
Next on the list was the decorator pattern. Although similar to the proxy, it works in a completely different way. A decorator wraps an interface and enhances it...