🎨 Design Patterns (Gang of Four)
Beginner
What is the Adapter design pattern?
Answer
The Adapter pattern converts the interface of a class into another interface that clients expect, allowing classes to work together that otherwise could not because of incompatible interfaces. It acts like a real-world power plug adapter. For example, if your app expects a Logger interface but you want to use a third-party library with a FileWriter class, you create a FileWriterAdapter that implements Logger and delegates calls to FileWriter. This lets you integrate legacy or third-party code without modifying either the client or the existing class.