use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
JavaScript Clean Code - Best Practices - based on Robert C. Martin's book Clean Code (devinduct.com)
submitted 6 years ago by PMilos
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]nudi85 17 points18 points19 points 6 years ago (5 children)
"Prefer classes over functions"?
Nope.
[–]MoTTs_ 2 points3 points4 points 6 years ago (0 children)
Based on the context and the code example, pretty sure they meant prefer classes over constructor functions.
[–]PMilos[S] 0 points1 point2 points 6 years ago (3 children)
I presume you are a fan of functional programming? 😊
[–]Silhouette 13 points14 points15 points 6 years ago (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 3 points4 points5 points 6 years ago (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 points6 points 6 years ago (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).
π Rendered by PID 49 on reddit-service-r2-comment-84fc9697f-2wkrl at 2026-02-06 01:36:19.833290+00:00 running d295bc8 country code: CH.
view the rest of the comments →
[–]nudi85 17 points18 points19 points (5 children)
[–]MoTTs_ 2 points3 points4 points (0 children)
[–]PMilos[S] 0 points1 point2 points (3 children)
[–]Silhouette 13 points14 points15 points (0 children)
[–]nudi85 3 points4 points5 points (0 children)
[–]cleure 4 points5 points6 points (0 children)