> I've never witnessed a need to "swap out" an entire layer. Have you?Many times, but the code assets (and the examples) are not ones that I can share. Feel free to dismiss it, if you like. I won't lose sleep over it.
What I can share, is that I have written frameworks in technology that is either deliberately "low-tech," or that is something that I know will probably not age particularly well, so I make it easy to replace. One example that I can give, is the BAOBAB server, that I wrote a couple of years ago[0]. It has four layers, and the ANDISOL layer[1] is the one that acts as a programmatic façade to the SQL-based database layers, below. It is explicitly designed to be the "swap out" point for the system.
In reality, I would suspect that this would only be the first part of a swap that would eventually replace the BASALT layer[2], but it would allow a graduated, incremental replacement strategy (I have done these a number of times. They are not for the faint of heart).
For example, when I talked about adding a command to the API, I just added one a few days ago, where I added a call to return a fast list of user IDs and display names[7]. I needed this for a "look-ahead" text entry autofill, in a social media app that I'm building on top of BAOBAB.
I could have easily added this to BASALT, and that would have been that. It would have been fast, quite safe, and wouldn't have required the elaborate nested submodule synchronization that is required when I tweak BADGER[3].
The problem is, that the command was a low-level SQL call, at its heart, and those belong in BADGER or CHAMELEON[4]. They certainly should never be exposed above ANDISOL.
So I added it to BADGER, then implemented a "pass-through" in CHAMELEON, and in ANDISOL (what is exposed to BASALT). Since BADGER is nested inside of CHAMELEON, which is nested inside of COBRA[5], which is nested inside of ANDISOL, which is nested inside of BASALT, I had to bump each of their versions, and update the submodule (I despise Git submodules) chain for each.
This is a fairly trivial example, but I take things like modularity, and domains fairly seriously. Also, it's a good way to keep security[6] fairly high.
This may not have answered your question, but it might help you to see how I work.
[0] https://riftvalleysoftware.com/work/open-source-projects/#ba...
[1] https://open-source-docs.riftvalleysoftware.com/docs/baobab/...
[2] https://open-source-docs.riftvalleysoftware.com/docs/baobab/...
[3] https://open-source-docs.riftvalleysoftware.com/docs/baobab/...
[4] https://open-source-docs.riftvalleysoftware.com/docs/baobab/...
[5] https://open-source-docs.riftvalleysoftware.com/docs/baobab/...
[6] https://riftvalleysoftware.com/BAOBAB/PDFs/Security.pdf (Opens a PDF File)
[7] https://github.com/RiftValleySoftware/baobab/commit/d8316a1b...