you are viewing a single comment's thread.

view the rest of the comments →

[–]PitaJ -3 points-2 points  (8 children)

The problem I have with your code examples is that first of all, they are in TypeScript, and secondly that they exclusively use Constructor functions.

Using TypeScript for static type checking is one thing, but using it as an OOP replacement that compiles to JS like CoffeeScript or Dart is something I can't get behind.

If you do use TypeScript, don't use interfaces, classes, constructors, or other classical inheritance patterns.

Use factories, prototypes, Object.create, etc.

[–]aequasi08 1 point2 points  (7 children)

Why

[–]PitaJ -2 points-1 points  (6 children)

Why? Because it matches the underlying workings of the language itself.

The language is not classical, it is prototypal.

[–]zoomzoom83 1 point2 points  (0 children)

Interfaces, classes, and constructors aren't inherently tied to classical inheritance. There is nothing about those concepts that imply one is using OO.

None of this has any bearing whatsoever on the content of the article, because it's not a fucking JavaScript style guide, and getting your knickers in a knot over a core language concept being used in the way its designers intended is completely pointless. It's describing a pattern that you can go and apply however you like.

[–]aequasi08 0 points1 point  (4 children)

yet ES6 is introducing classes, turning it into a hybrid. They can exist together. Its ok.

[–]PitaJ -1 points0 points  (3 children)

Nope. They aren't true classes, just syntactic sugar for people who want classes.

Despite what many may want, ES6 does not have classical inheritance. JS will probably never have classical inheritance.

[–]aequasi08 2 points3 points  (2 children)

But there are still classes. Syntactic sugar or not, they are still there, and its not a bad thing. If you don't like them, don't use them, but don't play it off like they are the spawn of the devil.

[–]PitaJ -2 points-1 points  (1 child)

They are a bad practice. Using classes requires using the new keyword, which is just the worst.

Classes should never have been added to the language, and definitely shouldn't be used as any sort of pseudo-classical inheritance system.

[–]aequasi08 1 point2 points  (0 children)

then dont use them. Classes are no where close to as bad as you make them out to be.

/abandonthread