“Open” for extension, “Closed” for modification In other words, it should be easy to add functionality to the system without modifying existing code.
All sub-types should be drop-in replacements.
(Funny: I thought it was for Inversion of Control, which is basically the same as Dependency Injection).
Instead, interfaces should be small and compose-able.
and last, but not least:
Instead of configuring and wiring up our dependencies, we allow them to be injected.
This is made much easier with the use of well-defined interfaces.
Instead of using a toggle switch to activate a blink circuit wired to a flashing light, we tell the boss: I need a panic button.
Then, the boss hands you a button.
It’s up to the boss if the button:
You’re sending The Wolf?
$#@!, Negro - that’s all you had to say!
— Jules Winnfield
We depend on that button working. But we invert who controls it and let them inject it into our system.
The part that confuses me is that when we are writing software, we are:
So it gets fuzzy if we can’t imagine which part of our software represents which of the different roles.
(We are not, however, The Wolf; That’s Harvey Keitel.)
.