loading...

re: Object Oriented JavaScript VIEW POST

TOP OF THREAD FULL DISCUSSION
re: But... That's not OOP. That's prototypal inheritance. Classes in JavaScript are just syntactic sugar. They're not classes like in OOP languages.

Actually this is a terminology war. Your definition of OOP is that it cannot contain the perfectly legitimate ECMA compliant Class. The reason, you say, is because it's internal implementation uses the prototype inheritance
(PI) system. Which you refer to as inheritance and call 'syntactic sugar'.

Nonsense. The word inheritance alone, as used above does not mean PI. Google and 25 years of OOP show that clearly. Besides OOP folks don't favor inheritance, they favor composition, just like Javascript does.

Besides all OOP winds up at small reusable functions anyway. It's much cleaner and easier to use the class than writing out verbose PI statements for properties.

Making a statement like 'not good for small projects' in my mind, is only a Javascript centric way of thinking. Using the Class construct is legit and ultimately has zero run time performance effects. For many OOP centric people it's a preferred choice. Besides sugar in any form is sweet.

Let's take a step back. I think you're getting a little defensive.

Your definition of OOP is that it cannot contain the perfectly legitimate ECMA compliant Class. The reason, you say, is because it's internal implementation uses the prototype inheritance (PI) system

Actually, that's not at all what I said. I said that JavaScript classes are not classes in the traditional OOP sense. A class in JS is just a function, and JS is fundamentally a functional language.

Nonsense. The word inheritance alone, as used above does not mean PI.

Good, because I never said that. I'm not sure I understand what you mean.

Besides OOP folks don't favor inheritance, they favor composition

Debatable. In my experience, people reach for inheritance way before it's needed and create unnecessarily tangled messes. But of course, this depends on the developer.

Making a statement like 'not good for small projects' in my mind, is only a Javascript centric way of thinking

To be fair, I wasn't the one who said that. There is no problem with using the class construct in JavaScript. Again, it's just syntactic sugar for something that's existed in JavaScript for a very long time: prototypal inheritance.

JavaScript classes are not classes in the traditional OOP sense

Internals aside there's little difference in how they behave in JavaScript and C# for example.

I'm not sure I understand what you mean.

JavaScript folks freely mix the words OOP and Inheritance when 1) They really know little about OOP and 2) They really mean Protypal Inheritance which is not the traditional meaning of the word Inheritance.

Debatable.

If you are seeing anyone favor inheritance over composition then you are working with junior level developers.

There is no problem with using the class construct in JavaScript.

The whole point of my replies. Plenty of folks will prefer the simplicity of using the Class over (PI). I'm one of them

I'm not really defensive, just willing to challenge absolute statements that are not universally true.

Code of Conduct Report abuse