2 ms·
It all looks very tidy when you see it set out like that.
by codeulike 9y ago
It all looks very tidy when you see it set out like that.
- BigJono 9y agoI love prototypical inheritence. I find it much tidier and easier to understand than the class based inheritence in other C family languages. I really wish that class syntax did not become a thing in Javascript. IMO that was the biggest mistake made so far in it's development. Just call a spade a spade instead of piling another level of abstraction on top.
- kowdermeister 9y agoIt added a bunch of other useful things, like getters/setters, constructor function, simpler method descriptions, etc. I don't have a problem with the class title, after all it describes a class of things. When you extend something you really extend the scope of your class, so I still find it adequate. There are differences in OO behavior between Java and C# but I haven't heard people complaining about naming classes classes.
- mileycyrusXOXO 9y agoThat is because Java and C# use classical OO. Javascript does not, it uses prototypal OO. Classes are static contracts that define the state and behavior of object instances. Javascript objects are not contractually obligated to have the state and behavior of a 'class'.
- kowdermeister 9y agoI know that and probably that's why people feel a bit annoyed by the Class keyword. However it's really close to what classes should represent. https://en.wikipedia.org/wiki/Class_(computer_programming) https://en.wikipedia.org/wiki/Class_(computer_programming) first two paragraph matches the JS use case well. > Javascript objects are not contractually obligated to have the state and behavior of a 'class'. I don't know what you mean by "contractually obligated", but if I instantiate a class in JS then it will have a state and behavior I defined in that class. If your problem is that if I change that class later, then the instances will change as well, then yes, it works like that. Calling something a class in my mind is not strictly limited to classical OO, it's just a loose concept different languages implement differently.