From the course: Go Design Patterns
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Adapter pattern overview - Go Tutorial
From the course: Go Design Patterns
Adapter pattern overview
- [Instructor] The adapter pattern is a structural design pattern that describes a way for the interface of a given class or type to be used as if it was a different interface without the need to modify the code of the existing class. This kind of situation arises pretty often in software development, especially when you're developing applications that need to access systems that are older and based on legacy code bases that you are reluctant to change or can't change. Or when you are working with APIs and subsystems that you don't have ownership of and can't make any changes to. The adapter pattern really becomes useful in cases like these where you need to take incompatible objects and find a way to make them work together, and we'll see an example of this in a separate video. So to better understand this, let's consider a diagram that explains the relationship between the adapter, the client class, and the target class.…