When should I continue to make derived classes, and when should I just add conditionals to my code? eg for a missile
class Object;
class Projectile : public Object;
class Missile : public Projectile;
class MissileGuided : public Missile;
Or should I implement that last one in the missile's code?
void Missile::Update()
{
if(homing && ObjectExists(Target))
TurnTowards(Target.Pos)
Pos += Motion;
}
I'm thinking that for all the finer details the second one is better, because you start getting combinations of things (eg some missiles may not show on the radar, some may be destroyable, some may acquire new targets if the original is destroyed or out of range, etc)
However then the same could be said for regular projectiles sharing properties of missiles in some cases (eg may be destroyable, large projectiles may show on radar, etc)
And then further I could say that projectiles share properties with ships (both move, on collision they do damage, may show on radar, may be destroyable...)
And then everything ends up back as like 3 classes:
class Entity;
class Object : public Entity;
class Effect : public Entity;
Where is a good point to draw the line between creating derived classes, and implementing the features in the method with flags or something?