10 The Adapter and Façade Design Patterns
In this chapter, we tackle an all-too-common problem: working with legacy software. This code can be from a library that we can’t modify, or it may be other external code that we don’t have access to or otherwise cannot modify.
The Adapter Design Pattern provides a model for a software architecture that needs to integrate external code with code in an existing application. However, the external and application codes weren’t originally designed to work together, and we cannot change either of them. The pattern can also help to isolate an application from interface changes in the external code that may be outside of our control. Our example application must generate a report about the attendance and venue of various school sports, but each sport reports that data differently.
The Façade Design Pattern provides a simpler, higher-level interface that makes complex code that we can’t modify easier to use. Our example application must interact with multiple organizations to raise funds for school sports.
Note Be sure to read the introduction to part 4 of the book for important information about design patterns in general and to learn how this and subsequent chapters teach each pattern.