April 2019
Intermediate to advanced
360 pages
9h 17m
English
The adapter design pattern is used to convert an interface of one class into another interface expected by the system. This design pattern empowers classes to work in concert with one another regardless of the compatibility of their interfaces.
Consider the real-world case of a motorhome. In order to connect to shore power, an electric cord is plugged into the motorhome. The other end of that cord is plugged into a power source receptacle. If the power receptacle does not fit the plug, an adapter is required. We can translate this real-world scenario into a computer model. The motorhome and power source receptacles are both classes with their own interfaces. These interfaces restrict the two classes ...
Read now
Unlock full access