The adapter pattern
The name adapter is derived from the real world, wherein we have various adapters being used in electrical and mechanical domains. While building an application, we often come across scenarios where we have to integrate with other applications/code, which are incompatible. Often, this results in lots of changes being made to either the base code or third-party code. But, in real-world scenarios, there can be various reasons wherein changes cannot be made to either the base code or third-party code or even both.
Note
The adapter design pattern enables two incompatible classes to interact with each other, without those classes knowing about each other's implementation.
Universal Call Center is expanding and wants to enable its customers to pay via credit cards for their services. Assume that there is a third-party library available named PaymentForYou
, which helps processing payments using PayPal. So, developers created a class that will send the payment processing request...