One of the most common intuitions people have in object oriented programming is that inheritance models an “is a” relationship between objects whereas composition models a “has a” relationship between objects. In the case of composition, this intuition is valid and causes no problems. Unfortunately however, the corresponding intuition for inheritance is actually wrong, despite how extremely popular it is.
The problem is that inheritance only actually models a small subset of possible “is a” relationships, and thus when programmers have the habit of thinking “I should use inheritance!” whenever they see any “is a” relationships the inevitable outcome is nearly always a poorly designed representation of the relationships between the objects being modeled.
Continue reading Contrary to popular opinion, implementation inheritance is not a conceptually correct representation of an “is a” relationship in programming.