News for hackers. Stuff that matters.
Re:The Two Pillars of JavaScript: Part 1: How to Escape the ... by bsaul on Saturday December 13, 2014 @08:11AM (#8745108)
The mantra "inheritance is the root of all evil" starts to bore me. Dot net framework is object oriented and uses inheritance. Java core API / standard lib is object oriented and uses inheritance. Every single iOS framework is object oriented and uses inheritance ( the ones written in Objective C at least). Android api are object oriented and use inheritance. Even Operating systems have been built with object oriented designs from scratch and ended up working quite well ( BeOS).

So please, next time you say that it's impossible to build anything big and reliable with this design because YOU or people you know ended up in a mess, think again whether the problem really comes from the language, or the people.

Re:The Two Pillars of JavaScript: Part 1: How to Escape the ... by fsloth on Saturday December 13, 2014 @09:46AM (#8745261)
I think there is a difference in inheriting from an abstract interface and constructing deep inheritance trees. The former is great in .Net for e.g constructing iterable collections and as such are more like glue between the language syntax and a concise implementation.

Deep inheritance trees, on the other hand, are difficult to use beautifully but yet are often portrayed as a first class design pattern which often ends up in mess. A priori designed inheritance trees without experience how such designs evolve in production are probably one of the biggest issues, I would imagine.

I think deep inheritance is an expert design tool that is easy to get wrong... therefore I kinda agree that the first advice "don't use it" is not misplaced but should be probably followed with "unless you really know you need it".

Since Javascript is a dynamic language it is easy for me to imagine deep inheritance trees will lead there to a terrible mess quickly since there is no static type system to enforce the design constraints.

Re:The Two Pillars of JavaScript: Part 1: How to Escape the ... by calinet6 on Saturday December 13, 2014 @10:05AM (#8745305)
I think people make mistakes in the architectural design part, often attempting to object-orient things that are not related in the strict way inheritance implies.

So, put more simply, don't make an Animal class if you have a Cow and a Tree, or you might end up treating legs and trunks the same. It should be no surprise, then, that bad things happen.

This is not the fault of the concept of inheritance, it is a fault in your thought process and the resulting design.