From the course: Python: Design Patterns (2021)
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
Bridge - Python Tutorial
From the course: Python: Design Patterns (2021)
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.