I've always viewed Starfleet space frames as being pretty modular. Most bits could be swapped out when required.In the Star Trek world lots of ships do. DS9 battles were full of impossibly old ships.
Also, the volume of Federation space will increase massively with every light year added in any direction. Supply routes, communications, general trade and patrols, Starfleet could not supply enough new ships - with subsequent generations of new designs, older ships would be assigned non front-line duty but not scrapped.