Bad analogy. B-17's aren't around anymore in war because they lack several critical technologies deemed necessary for combat roles (cabin pressurization, jet engines) and several which are obsolete (manned gun stations, ballistic armor).
And were not suitable for upgrades to these technologies, which is my point. Furthermore, even if they WERE capable of sustaining the upgrades, a more capable platform already exists that makes the upgrade pretty much a waste of time. It would be more efficient to build more F-16s or even upgrade some F-4s; in the Starfleet analogy, it doesn't make sense to upgrade a Miranda class with 24th century technology when more modern designs for the same mission role already exist; it makes even less sense to build a brand new Miranda class to new modern specifications.
A Miranda (or Excelsior, the exact model doesn't matter) uses the same basic warp technologies as a Galaxy.
DOES it? We don't even know this for sure, only that both are equipped with warp engines. If the fundamentals of the technology are that interchangeable, then the Akira class might as well be a refitted NX-01.
And it still leaves the question of why OTHER designs from the same era are out of service. The Constitutions, for example, could fill some of the same mission roles as the Mirandas and Constellations (and maybe even some of the Excelsiors) and yet have completely vanished by the 24th century. This is difficult to reconcile with the existence of modern designs in the exact same niche, notably the Nova and Intrepid class vessels, which would immediately render the old designs redundant (or else what would be the point of building them in the first place?).
The more likely scenario would involve a kind of modularity, maybe starships with double hulls where internal modules can be swapped out within the same outer hull, and then the outer hull gets swapped out to change the ship's external appearance despite the interiors remaining the same; change the impulse engines every ten years, warp engines every twenty years, weapons every twenty five and reactor core every thirty. You'd end up with a flying ship of theseus that can last a hundred years and continue to change as it continues to be upgraded (like the Essex class ships from WWII). But by no means would you expect to see--in 1985--an Essex class carrier that looks the same as it did forty years earlier, and the same should be true of starships. If the Miranda class is still in service in the 24th century, I wouldn't expect it to look ANYTHING like the 23rd century version except with the same
basic hull shape and the original registry number; basically, it would be a dead ringer for the Nebula class except smaller and without the engineering pod.
Starfleet has infinite resources? Since when?
Semantics. You don't really need infinite resources. Just enough to economically sustain both the old ship and the new in both roles (which may be different if the new ship supplants the old in its primary role) without sacrificing something.
That's alot more than semantics. If you have enough to sustain both, then dropping the one necessarily enhances the capabilities of the other. The resources spent on sustaining an old Excelsior could also be spent on BUILDING a new Intrepid. This, mind you, is one of the reasons the Iowa class battleships are no longer in service despite their many weapon and technology upgrades.