课程: Advanced Python: Build Hands-On Projects with Design Patterns (2023)
免费学习该课程!
今天就开通帐号,24,700 门业界名师课程任您挑!
Adapter pattern - Python教程
课程: Advanced Python: Build Hands-On Projects with Design Patterns (2023)
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.
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。