However, I think it would be slightly annoying if you had to build a shipyard and then immediately retool it so this is a case of game-play over realism but with a reasonably plausible explanation behind it.
I could live with that if shipyards cost less. Because currently, I tend to shuffle around shipyards and always keep a few freshly built new ones on expansion so I can use any new class immediately.
It also helps to have set tonnage ranges for classes that never change (2kton corvette, 3x 6kton frigate, 3x 6kton sensor platform, 2x 10kton destroyer, 12kton C&C, 16kton missile cruiser, 20kton battleship, 24kton independent patrol, 50kton commercial jumpship) so you already know ahead of time when you want to stop expanding a yard.
Idle ones (classes I'm not building atm or fully expanded yards) get "mothballed" by the fleet of space stations that are nothing more than a tractor beam.