tl;dr - Large components of systems you build deserve an interface, even if there is only ever one implementation. If you want your code to be good, put a bird interface on it!
I’ve gone back and forth, but for the last maybe 5 years my opinion has hardened. My stance is now that it is unquestionably right to always build an interface for large components of a given system, even if you only have one implementation early on.
Here’s why:
I’ve seen this play out numerous places – here are a few which are top of mind:
I’m not saying you have to go all the way and build in a runtime-loadable plugin system! But please at the very least build in some leverage so that people can safely do some new construction on bits of your majestic software house.
What I see often is that people will use a database library that has support – note that this is not what I mean. Often this makes a project worse, because they have to stick to writing subsets of SQL that are cross-DB. It’s much better to have a DataBackend
that has implementations like Postgres14DataBackend
and MySQL8DataBackend
rather than just changing the driver: 'postgres'
to driver: 'mysql'
in some configuration file.
That said, I’m thankful for whenever projects at least have the SQL driver thing going – cross-platform SQL is often good enough.
Disclaimer: I’m clearly greatly biased in favor of Postgres, as evidenced by this hot take and previous posts.
MySQL is truly great software (most of the modern internet is built on the LAMP stack, it has great features and stability), it’s more that Postgres is amazing.
The things Postgres does and can do, the way people build on it, the way it’s been governed, improved and continues on are exemplary – that’s why I’m always eager to see it in more places.
Also, as long as I’m doing random hot takes no one asked for, Ghost’s decision to remove Postgres support was the biggest mistake they’ve ever made (the software, organization and people that makes Ghost is amazing though – it’s an insane value and they legitimately make the world better).
In the recent release notes for Ghost 5, the team doubled down on MySQL 8.0 – likely a great thing for their productivity, though a bunch of SQLite users will be sad. The real pain for me was finding out about their decision from so long ago to drop Postgres support. I do appreciate their generosity and transparency in sharing their reasoning – Ghost is run is a breath of fresh air, and the amount of value they deliver for free (and with paid plans) is insane.
They’re not completely against re-adding it, but the chances of that are slim to none – an interface around the one implementation could have helped others (who cared enough) maintain a separate plugin though. I mean even if you weren’t a Postgres fanatic, it might be cool to try running ghost on something more exotic, like Object storage or Git!
It’s a spicy meatball take (also something a junior engineer/sith might say), but Postgres is strictly better than MySQL, full stop.
MySQL 5, MySQL 8, doesn’t matter, doing lots of concurrent transactions or not, I want Postgres 100% of the time that I see MySQL, and it puts me off using entire projects.
In short – if you want your code to be cool, put a bird interface on it!