Choosing a composition over inheritance is one thing.
Many people, especially those new to OO, will begin to extend classes when all they really need is to use composition. Indeed, if you must ask yourself, is the new class B a class A? If not, you should not spread.
For example, let's say I have a Person Class, a Car class, and I would like to create a new class with a DrivenCar class. A naive implementation would be to say (let it pretend we got multiple inheritance)
class DrivenCar extends Person, Car { ... }
Is DrivenCar a Person Type? No, therefore, he should not expand the Personality. Is DrivenCar a car? yes, so it makes sense to expand
Using composition, the implication will look like
class DrivenCar extends Car { private Person driver; }
source share