How should I give gameobjects health?

I’ve been watching allot of videos teaching me about inheritance, interfaces, polymorphism etc, and I’m thinking about starting on a new project using what I’ve learned to make a bigger game than I’ve ever made before, but I don’t know what tool I should use to do what because there are endless ways to do basically anything, and I want to go the most practical route.

I thought about implementing inheritance by creating a humanoid class as the base class, containing all of the basics like pickUpItem() and takeDamage().

However, what if I want more classes, other than just humanoids, to be able to take damage?
Should I make one component that deals with health and spread it on everything I want to be able to take damage?
or should i make an interface like IDamagable that other classes that I want to be able take damage implement?
or should I go a bit extreme and make every single class that should take damage inherit from a class that contains a function that deals damage?

If I decide on using either a component or an interface should I remove the takeDamage() function from the humanoid class and make them use a component or an interface like all the other classes/objects do?

I normally decide how I write my code based on this:

  1. what will make it harder for bugs to appear

  2. what will make the code more easy to understand in case I need to go back to it to change later

  3. what I am more confortable with

In your case I would probably make a script that contains health and other data that the objects that have health also have and name it UnitStats or UnitInfo. Just because it matches the 3 conditions better than other alternatives (I look at the script name and I already know exactly what it is about and it will be easy to understand and make changes). But you might be more confortable with another approach

But seriously. I think it’s one of those things that you learn better when you do it the wrong way. It makes you give more value and feel better when you know exactly what you are avoiding when you are writing your code the “correct” way