The Component
Inheritance patterns have existed in JavaScript since the beginning, first in the form of prototypal inheritance and then class syntax since ES2015. Some programming paradigms have recommended leveraging inheritance as the primary tool for building complex applications. For example, if we were building a website that included a profile page for a pet kitten, you might think about setting up an inheritance chain such as KittenProfilePage extends FelineProfilePage extends PetProfilePage extends ProfilePage extends Page
. Indeed, some UI frameworks have attempted to implement models like this. However, in practice, this kind of thinking is quickly revealed as overly rigid, resistant to changing requirements, and forcing you into strange patterns. For example, if we have implemented whiskerCount
in FelineProfilePage
and we're now implementing RodentProfilePage
, do we copy and paste? Does RodentProfilePage
inherit from FelineProfilePage
? Should we introduce WhiskeredPetProfilePage...