August 2018
Intermediate to advanced
332 pages
9h 12m
English
The adapter pattern is probably one of the simplest design patterns there are, and one of the most useful ones at the same time. Also known as a wrapper, this pattern solves the problem of adapting interfaces of two or more objects that are not compatible.
We typically encounter the situation where part of our code works with a model or set of classes that were polymorphic with respect to a method. For example, if there were multiple objects for retrieving data with a fetch() method, then we want to maintain this interface so we don't have to make major changes to our code.
But then we come to a point where the need to add a new data source, and alas, this one won't have a fetch() method. To make things worse, not only is this type ...