4. When is classical inheritance an appropriate choice? The a | Learn JavaScript™
4. When is classical inheritance an appropriate choice?
The answer is never, or almost never. Certainly never more than one level. Multi-level class hierarchies are an anti-pattern. I’ve been issuing this challenge for years, and the only answers I’ve ever heard fall into one of several common misconceptions. More frequently, the challenge is met with silence.
“If a feature is sometimes useful and sometimes dangerous and if there is a better option then always use the better option.” ~ Douglas Crockford
Good to hear:
Rarely, almost never, or never. A single level is sometimes OK, from a framework base-class such as React.Component. Favor object composition over class inheritance.
All info, tutorial, JS tips and more ....!. bio.link/javascript_js_. For HTML: @html_web_learn. For CSS: @CSS_web_learn. For JS: @JavaScript_js_learn. For PHP: @learn_php_web. For Programming courses...