The Problem
When creating dynamic web apps, JavaScript is an amazing tool which enables us to write functions that can be used to manipulate the D...
For further actions, you may consider blocking this person and/or reporting abuse
For smaller projects OOP could be a bit of overkill, but for mid-size and larger apps where complexity kicks in, its spot on.
No wonder companies mainly go OOP, as it ensures higher level of re-usability, scalability, code-redundancy and maintenance options.
*There's a typo, (fix typeOfCar to model) in goVroom function.
It's a mixture between ability to identify the most appropriate tools for specific tasks and personal preferences. To me, OOP happens to be where it's at cause of massive amount of CRUD systems in corporate world.
No mention of inheritance was made. What was shown was merely a class definition with methods.
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.
Internals aside there's little difference in how they behave in JavaScript and C# for example.
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.
If you are seeing anyone favor inheritance over composition then you are working with junior level developers.
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.
Great example and well explained. Thanks :)