The question I have is when will a ship be fully obsolete? The only thing I can think of is if they change the warp drive to something faster. Even in a money free society, it is expensive to construct a ship. It seems that it would always be economical to strip out obsolete systems and upgrade them to new ones, i.e. refitting. The only way you get to be really obsolete is if an upgrade is not feasible, i.e. the drive requires a completely different chassis.
Hypothetically I think the D would have still been around had it not been destroyed. It might have even had a new saucer, or drive section built if only one survived. Or a cut and paste 3rd nacelle a la AGT.
F-16s are still being produced and have been in service for over 40 years. The F35 will probably be around for a while too. If we are able to keep using a 40 year old jet, I would expect a utopian future to find ways to squeeze much more usage out of something ~10,000 times bigger in volume.