The adapter pattern
The adapter design pattern is employed when a component in your system doesn't provide an appropriate interface, API, or surface to make it compatible with the rest of the system. Adapters can be thought of as real-world adapters, or dongles.
There are a number of ways to implement the adapter pattern in Swift by leveraging inheritance, aggregation, or extensions.
Using the adapter pattern
When building an app, a program, or a web server, it is good practice to configure logging or analytics so it is easy to inspect program behavior at runtime. When running on a debugger or deployed on a user's device, or on a server, requirements for logging or recording analytics may change. During development, for example, it is not recommended to send analytics to the production server.
The adapter pattern is a great way to abstract and connect different logging or analytics infrastructures or classes, depending on runtime. It is based on the idea that classes will wrap your specialized...