The adapter pattern

The adapter pattern is used to make one object work with another. Say that we need to integrate two subsystems, but they cannot talk to each other because the interface requirements are not met. In real life, you may have encountered a situation where traveling to a different country is troublesome because the power plugs are not the same. To solve this problem, you would probably bring a universal power adapter, which acts as an intermediary to make your device work with foreign electrical outlets. Similarly, different software can be made to fit with each other by the use of adapters.

As long as the interface for working with a subsystem is clear, then creating an adapter can be a straightforward task. In Julia, we can ...

Get Hands-On Design Patterns and Best Practices with Julia now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.