From the course: Advanced Python: Build Hands-On Projects with Design Patterns (2023)

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Adapter pattern

Adapter pattern

- [Narrator] The adaptor pattern converts the interface of a class into another one a new client expects as needed. Adaptor is a structural pattern. Our problem is that different interfaces are necessary between a client and a server as new clients appear. In our scenario, we have Korean and British objects that have different method names for speaking. The client would like to use a uniform interface that is the speak method. Our solution is to use the adapter pattern that switches the method names between the client and the server code, depending on the language to be used.

Contents