Components smaller, more specialized or bigger, more generic

Which approach to design components is better?
Let’s take for example some explodable object:

class Explode {
   public GameObject explosionPrefab;
   
   public bool explodeOnTimer;
   public float timeToExplode;
   
   public bool explodeOnCollision;
   
   public bool explodeOnDamage;
   public float minDamageToExplode;
   
   public bool explodeOnDie;
   //...
   
   public void Start() {}
   public void OnCollisionEnter(...) {}
   public void OnTakeDamage(...) {}
   public void OnDie(...) {}
   //...
   
}

… or maybe…

class TimerExplode {
   public float timeToExplode;
   public void Start() {}
}

class CollisionExplode {
   public void OnCollisionEnter(...) {}
}

class DamageExplode {
   public float minDamageToExplode;
   public void OnTakeDamage(...) {}
}

class DieExplode {
   public void OnDie(...) {}
}

In other words, should I design small, more specialized components or bigger and more generic?
I know the first example is better in scenarios where I want some objects to explode on many different conditions - it’s only one component and few checkboxes.
But with the second example I can just add new condition/new event (for ex. ActivatorExplode to explode on activation by other object) as new component and don’t worry that new code could somehow affect or break behaviour of already created objects/prefabs. Ofcourse now there are many many small components and objects are getting messy.

Or maybe I don’t need all this conditions. Maybe I should add to my explodable object just Health component, which sends OnDie() message when health<=0, and Explode component which reacts to only this one message spawning explosion object. Health component could have all this conditions to decrease health value. Then to make timed bomb I’d just add TimedDamage component that will send OnTakeDamage() after few seconds.

But then, what if I want some object to explode only when its taken damage for example by flames? You can shoot it, you can break it and it dies but it only explode when you heat it with fire?

This questions aren’t only for this example, I’m asking about some general tips for: what level of functionality should I split into components? Should I make NPC component or rather NPC_Attack, NPC_Defense, NPC_Civilian, NPC_Soldier, NPC_PathFollower, …
… should I make a generic Grenade script or maybe TimedExplode, StickToWall, CollisionExplode, RadiusDamage, … to be able to create many different grenade and maybe bomb types? How big or how small this LEGO parts should be?

P.S.
Sorry for my bad english, still learning :frowning:

I’m only a hobby programmer, but here’re my two cents…
I think having multiple same level classes that implement the same functionality with few changes should be avoided. Unless absolutely necessary don’t write a piece of code more than once. If you need different Explosions write a base class and derive more specialized types from that. When it comes to the size of a class I’d distinguish between reusable components and those that implement specialized gameplay mechanics and are unlikely to be reused in a future project. The latter ones could probably be a bit less specialized, reusable ones should be small to allow users to combine them with other components in wicked ways. In any case you should make sure that the class is not an omnipotent behemoth, is properly encapsulated and has an user friendly interface.

Speaking about NPCs: I guess I’d try to code a finite state machine. Unless they’re rocket scientists this should work :~)

Thank you for your answer.
Ok I can make some base classes and derive more specialized ones from them but I still don’t know what to do in particular cases. Maybe it’s because I’m familiar with entity systems with deep class hierarchies but unfamiliar with component based game objects. Maybe I should just try different solutions and find out what’s best.

Let’s take for example grenades.
In entity systems there are classes like: GrenadeBase, Grenade, StickyGrenade, DetonateGrenade, SmokeGrenade, FlashbangGrenade, …
In component-based system should I make similar class hierarchy and let game designer choose which component to use on particular object? Then what’s the difference beetween this and entities and class hierarchies?

To make a grenade game designer needs only Health and TimedExplode components, to make sticky bomb he needs Health, TimedExplode and Sticky components etc. Hey but to make a grenade he can also use TimedObjectSpawner to instantiate explosion prefab after some time. So maybe TimedExplode isn’t needed? But TimedExplode can do more than TimedObjectSpawner as it can react on message OnKilled() to explode anyway and TimedObjectSpawner only instantiate prefabs after some delay. So maybe derive TimedExplode from TimedObjectSpawner?

Maybe someone could give a list of example components he uses, I just need to draw in my head all this transition from entity hierarchies to component-based game objects.