202204272256 Create internal APIs on top of dependencies
When we use a dependency — whether first- or third-party — widely in our code, we should wrap that dependency in a simple to use, internal API which becomes the only way our app can use that functionality.
This is sometimes called the strangler pattern, but that term is also sometimes used for a different situation.
There are many benefits of doing this.
- When the dependency changes, there’s only one integration point. With well written tests, this makes dependency upgrades much easier.
- If we want to change out the dependency (a.k.a. the functionality implementation) for a different one, we only need to change the integration point. Our app-code consuming the internal API doesn’t need to change.
- We can change, adjust, modify, and iterate on an internal API much faster and more flexibly than we can for dependencies. Likewise, if the dependency API changes, we’re not required to go along with a new pattern that might be more cumbersome for our internal use-case.