In a lot of modern navies (Germany, France, Italy, Spain, ect), the rank that in the US (and Starfleet) is called Lieutenant Commander is called Corvette Captain. The rank the US (and Starfleet) calls Commander is called Frigate Captain. And Captain is above that.
So one of the things a Frigate should be is a ship small enough that her CO is a Commander.
Wikipedia mentions that Frigates were ships that, while the same size as a Ship of the Line, were less well armed.
I vaguely recall that a Frigate was a warship with more cargo capacity, which sort of follows: fewer guns means more room for cargo, and vice-versa.
Modern frigates often sacrifice some armament to make space for a helipad. This might just be part of their anti-submarine role,but perhaps this is part of
why they are designated as frigates: dedicating more space to non-combat (or non-direct, ship-to-ship combat) roles than a cruiser.
Which fits the Miranda to a tee, IMO: more space for labs and cargo, and maybe slightly less weapons than a cruiser. (Yes, we see a Miranda "outfight" a Constitution Class, but only when it got in a devastating first punch because Kirk kept his shields down. IMO, the Miranda of the period was not armed as well as the COnstitution, just close
enough.)
Destroyers and battleships should be vessels that are almost exclusively built for combat. As such, they are very scarce in Starfleet. IMO, the Defiant could be called either, although being small and maneuverable maybe destroyer is a better fit. I've seen it suggested that the Soverign Class is a battleship, but I'm not sure it isn't just a really big and well armed cruiser.
On the other hand, given the history of "cruiser" as merely a term for a ship intended (or tasked) with operating alone, without the support of a fleet, even a battleship could be a "cruiser" as well.
Corvettes are mainly identified by their speed. They should be smaller than a cruiser or frigate (if only to make the ranks make sense

), and it would be appropriate to give this name to ships designed for working in close proximity to planets, perhaps even entering the atmosphere. Voyager might be a really big Corvette.
So, IMO (and YMMV), Starfleet reserves the term "battleship" to be large ships with the best weapons and shields, with little non-combat facilities, that are specificly designed to operate in fleets (either with other ship types or in groups if like ships). Of which it has none.
Cruiser is the term for most Starfleet ships. Terms like "heavy" and "light" are used to classify them according to their combat capability (weapons, shields, etc).
Frigate is used to designate those that devote an unusually large amount of their space to non-combat equipment, making them less capable in combat than a typical ship of their size.
Destroyer is used to designate a ship that devotes an unusually large amount of their space to combat equipment, making them more capable in combat than a typical ship of their size
Corvette is for very small, highly maneuverable ships.
Some Starfleet ships are not really designed as multi-role ships at all, and these generally have a specific term describing the type of job they are designed to do, such as Science Ship, Freighter, Repair Ship, and Hospital Ship.
As for ships changing classification, remember that during TOS, the Constitution Class was the biggest ship we saw. Okay, it was the
only ship we saw, but there was the implication that it was the biggest, most capable class in the fleet. In the Movie Era, the Excelsior was bigger and more capable. By the TNG era, the Excelsior was pretty small (compared to the Ambassador, the Nebula, and the Galaxy Classes). So the Excelsior Class likely got downgraded as larger, better armed and more capable ships got introduced. If your standard for a Heavy Cruiser is ten science labs and 14 phaser banks, then you need to reclassify an old ship with six science labs and 10 phaser banks.
Over those 100 years, old Excelsiors and Miranda went through refits that brought their equipment up to date and at the same time reduced their crew requirements. At the time of at least one of those refits, the ship may also have been re-classified from cruiser to frigate, or from heavy cruiser to light cruiser, to reflect where the ship now fit among its peers.
Old COnnies may have remained in service, but .... well, I've always liked the idea that the Constitution CLass suffered horrible attrition. They were the best Starfleet had, and got sent to all the toughest situations, and that unfortunately meant that a lot of them didn't come back. When the Excelsior Class came along, construction of the Constitution stopped, but there weren't very many of them left anyway. Mirandas kept getting made, and kept getting assigned to comparatively safe missions, so most of them survived.
I like to think that the reason Starfleet wanted to retire the Enterprise-A and create a new Excelsior Class Enterprise is that she was the only Constitution Class ship left (except for the pre-refit Excalibur, which suffered the loss of all hands when attacked by the M-5 in control if USS Enterprise, and made an exhibit in the Fleet Museum). But that's all just my non-canon guesswork.