May 2024
Intermediate to advanced
676 pages
13h 30m
English
In the last chapter, we used the Decorator pattern to dynamically add new behavior to existing classes without using a traditional subclassing approach. In this chapter, we’ll stick with the idea of adding new behavior without touching an existing class, but this time, we’ll use interfaces to adapt existing incompatible classes to work together using the Adapter pattern (which is perfect when you need to force two unruly systems to play together nicely without overhauling either one).
Now, the Adapter pattern can be used for all kinds of situations, including porting an existing class into an interface your client code already uses, creating reusable classes that work with classes you ...
Read now
Unlock full access