My (biotech) employer largely solves this issue by keeping a copy of the formal research specs outside of software altogether. All validation documents and research data are kept in paper form (in addition to digital form) in such a way that future researchers or inspectors could take those documents and data and reconstruct the research.
It wasn't always this way, unfortunately. I've been involved with trying to glean some formulaic/methodological insights from spreadsheets and code and it's not always possible to reverse engineer the essential methodology or be sure that mistakes were avoided.
Proper scientific research practices are similar to proper data backup practices: the documentation (backup files) are important, but they don't matter if you can't have successful reproducibility (restoration).
In the life sciences provenance is as important as reproducibility, and you can use software systems to manage provenance. The paper requirement will go away over time. Even the FDA, which required paper in the past, is moving to an electronic model. But you do need to document methods somewhere and not just in code, a reference document which could be shared, even if the specific implementation is different
It wasn't always this way, unfortunately. I've been involved with trying to glean some formulaic/methodological insights from spreadsheets and code and it's not always possible to reverse engineer the essential methodology or be sure that mistakes were avoided.
Proper scientific research practices are similar to proper data backup practices: the documentation (backup files) are important, but they don't matter if you can't have successful reproducibility (restoration).