Consider creating a piece of software composed of modules such that any component can be easily replaced with another, independently written, compatible component.
All components can be replaced, especially including the module loader itself and related infrastructural glue.
Well documented APIs are the traditional, but very difficult, way to do this. Are there other ways? Pure functions without side effects will probably be useful.
A closed-source program could be gradually transformed to an open-source one. But linking licenses might get in the way (e.g., GPL in contrast to LGPL).