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 code, in order to provide a common interface. This is very useful when dealing with third-party libraries, on which the code isn't ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access