Decouple an abstraction from its implementation so that the two can vary independently
Let's take the definition above into practice by implementing a simple HTTP service abstraction with multiple implementations include React, Vue and Angular. First of all, we need to define an abstraction interface and the implementation of this interface like below
Next, we would like to have a interface definition for all implementations to match the bridge between abstraction and implementation as the pattern defines
And there we have it - the Bridge Pattern implemented in Go. With this pattern, the consumer code is totally unaware of the development of abstraction and implementation internally. We could have multiple abstractions and implementations as long as it matches the bride interface among the two. Moreover, they all can be developed independently without the hassle of any inheritance
P/s: The accompany code is included in this PR 😊
Happy coding 😎