The F-35 was trying to share more than just parts, but an entire airframe. Sharing parts is "normal", LRUs are designed to standard forms (both in connectors as well as physical box size, shape, and weight) on purpose. This allows them to use the same box in a variety of aircraft to cover the common subsystems.
A greater emphasis on these modular components being flexible enough to meet each mission need while permitting each service to get its own tailored airframe would have been the best option. Instead the F-35 program office has the population of a small town on its own who all have to coordinate in harmony (hah!) with each other and the customers who have very different actual wants and needs. Divide that into 3+ airframe program offices (of reasonable sizes) with proper focus on their customer, and one larger program office that oversees the various LRU and other components and this alternate F-35 family of aircraft could have been successful (at least some of them, even if, say, you end up trying to build 5 planes and only 3 really meet their goals, that's better than the F-35 which doesn't work for any of its users).
Even in the software design biz, factoring often looks easier on paper. Small-scale modules and components usually have a better reuse record in my observation because you can mix, match, change, and drop them as needed per project: you can date components without being forced to marry them. F-35 is a marriage made in Hell.
A greater emphasis on these modular components being flexible enough to meet each mission need while permitting each service to get its own tailored airframe would have been the best option. Instead the F-35 program office has the population of a small town on its own who all have to coordinate in harmony (hah!) with each other and the customers who have very different actual wants and needs. Divide that into 3+ airframe program offices (of reasonable sizes) with proper focus on their customer, and one larger program office that oversees the various LRU and other components and this alternate F-35 family of aircraft could have been successful (at least some of them, even if, say, you end up trying to build 5 planes and only 3 really meet their goals, that's better than the F-35 which doesn't work for any of its users).