On my love for interfaces
Last modified:
One of my favorite software principles is "program to an interface, not an implementation".
I like it because so many wonderful side-effects fall out of it.
- It forces you to think about your clients first
- You fully own the implementation
- Better, more targeted testing
- Loose coupling
- Better reuse
- Better composability
...and I'm sure many more.
All of those are wonderful. But at a deeper level, I think the reason I love it so much is because all of those side-effects promotes psychological safety.
- Thinking about clients - forces you to empathize and keeps you focused on the right problem
- Owning the implementation - gives you freedom to adapt
- Targeted testing - makes change safer, and lets you do it with more confidence
- Loose coupling - reduces fear of breaking unrelated code
- Reuse - validates that your abstractions hold up
- Composability - makes it safe to experiment and play
Principles like this endure because they’ve stood the test of time. The catch is that you rarely internalize them until you’ve felt them in practice.
Sure, they produce “better” software. But what is better?
To me, it’s software that solves the problem it set out to solve, adapts easily, and is something people enjoy both using and working on.
Good principles not only make your output better, they make you better at the work.