I'm trying to use composition in an
Entity class of mine. So far, an Entity "is"
Displayable(inherited an ABC), and "has" a
Position(contains a point-like class). I know I will want my Entity to "have" a/some health, so I started defining a
Health class to be composed into
Entity. It was super-simplistic though, and only ended up containing 2 methods:
heal that modify its single field:
If I intended to inherit from
Health, I guess this would be OK, as it wouldn't require any boilerplate inside of
Entity; it would just inherit the methods.
If I'm going to compose with it though, so for me to
Entity, I'll have to route the
heal call to their
Health member and call their own
heal method. With a class this simple, that means I'll basically have all of
Health's methods duplicated in
In a case like this, is there any point in defining
Health? The simpler alternative would be to just give
hp field, and give it the
heal methods directly.