- Keep your code reasonably clean
- Use strong typing
- Make sure your tests don't test implementation details if possible
- e.g. using more integration like tests written with react-testing-library
- e.g. using visual regression tests
- If you sense something is off about the tech stack make a POC of partially migrating to something else as soon as possible
- If the thing you tried is better come up with a plan to migrate and do it as soon as possible
- If you've followed all the bullet points above then switching to a better solution shouldn't be that difficult
That's how I try to deal with it. Also if you're not sure which thing is better do POCs with both solutions. Alternatively if you're working on a greenfield project and a week in things don't feel right don't be afraid to try rewriting it with one of the alternatives you were considering, it'll be a slight hit to productivity for a day or two but it'll pay off long term.
By following these guidelines I've never felt on a project that I've painted myself into a corner with the tech stack, or chosen something very bad that is not reversible.
By following these guidelines I've never felt on a project that I've painted myself into a corner with the tech stack, or chosen something very bad that is not reversible.