课程: Python: Design Patterns (2021)
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Bridge
- The bridge pattern helps untangle an unnecessarily complicated class hierarchy. Especially when implementation-specific classes are mixed with implementation-independent classes. The problem here is that there are two parallel or orthogonal abstractions. One is implementation specific, and the other is implementation independent. Our scenario involves implementation-independent circle abstraction and implementation-dependent circle abstraction. The implementation-dependent circle abstraction involves how to draw a circle. And the implementation-independent circle abstraction involves defining the properties of a circle and scaling it. Our solution is avoiding abstracting both implementation-specific and implementation-independent classes in a single class hierarchy. The abstract factory and adapter patterns are the related patterns to the bridge design pattern.