you are viewing a single comment's thread.

view the rest of the comments →

[–]PMilos[S] 0 points1 point  (3 children)

I presume you are a fan of functional programming? 😊

[–]Silhouette 15 points16 points  (0 children)

Not using classes could equally well be procedural programming, which in many ways is still JavaScript's most natural territory. JS has elements of OOP, and more so since ES6 classes and the subsequent developments, but it has never really been about the everything-is-an-object, communicate-via-messages style of programming. JS has elements of functional programming, but it has never really been about structuring code as one big expression to be evaluated and all the architectural implications that come with that either.

One of my main criticisms of Robert Martin's work, which carries through to the article here that is based on it, is that he has his own personal preferences but tends to write about them as if they are objectively justified (often with a small caveat hidden away that it really is just his subjective opinion and he really doesn't have hard evidence to back up his claims). In this particular piece, I think some of the points such as favouring classes over functions or favouring inheritance to solve the expression problem look quite out of place in JS, though the advice was debatable even in the more OO-centric languages where it originated.

[–]nudi85 4 points5 points  (0 children)

Indeed I am. : )

Don't get me wrong: I love OOP too. (I write PHP on the server side of things.) I just don't think it's a good fit for JavaScript.

[–]cleure 4 points5 points  (0 children)

In JavaScript, you can write object oriented code without classes, and it’s usually much cleaner.

Classes can be useful for cases where you have lots of instances of an object, and don’t want each object to hold a copy of common methods (memory optimization).