From the course: Design Patterns in Go for Object Oriented Programming

Unlock this course with a free trial

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

Adapter pattern

Adapter pattern

- [Instructor] Let's jump in and deepen our understanding of the adapter pattern. The adapter pattern is a bridge between two incompatible types. It uses one single interface and joins two different functionalities together. In the adapter pattern both sides of the connection are unaware that an adapter is being used to communicate with each other. The adapter pattern is helpful when you want to use a specific class, but it is incompatible with the rest of your code base. It is also helpful when you want to reuse subclasses that don't have common functionality but you want them to be joined together. There are two main types of ways that adapters are constructed. Object adapter and class adapter. The object adapter implements the interface of one object and then wraps the other object into itself. This structure can be implemented across all programming languages. The class adapter is where the adapter inherits…

Contents