The Branch By Abstraction pattern describes the injection of an abstraction layer within a software system, so that the part “behind the abstraction” can be switched out.
Initially, the system is directly accessed by other components:
As a first step, an abstraction is created, through which all direct access by the components happens henceforth:
Then the old system can be easily replaced by a new system.
Assuming the developers worked cleanly, this can be easy as providing a new implementation for an existing interface, or as complicated as conceptual scoping and separating the system-to-be-replaced, then defining an interface, then making the existing system the implementation, then replacing.
This pattern works on multiple levels of granularity, e.g.
- abstracting direct file access, so that an object storage can be used instead
- abstracting API use, so that a different provider can be used