Where the Branches Disappear
Shared interfaces let us stack software like building blocks, swapping what sits underneath without rebuilding what sits above.
I like imagining software as building blocks stacked on top of each other.
At some point, one block splits into two. Maybe one implementation runs in the browser and another runs on desktop. Underneath, they do completely different things. But they expose the same interface, so every block above them gets to treat them as one.
Application
|
Domain service
|
Shared interface
/ \
Browser implementation Desktop implementation
| |
Browser APIs Native APIs
You can keep stacking from there. You don’t need to carry that fork through the rest of the application. The interface gives you a place where the branches come back together.
And this can happen repeatedly. One layer depends on another, which depends on another. Somewhere below, there are three different ways to do something. Somewhere else, there are two. But at each boundary, the next layer only needs to know what it can ask for and what it can expect back.
That’s the picture that helps me understand dependency injection. You choose what goes underneath a block without rebuilding everything that sits on top of it.