[-] DonjonMaister@programming.dev 1 points 1 year ago

This is an excellent take! 👏

That said you should strive to use both functions and classes. If you can simplify your functions to allow mostly any primitive input, that’s great. It can be reused many times throughout your code. But if you have certain operations that only work with one type, then don’t be afraid to use a class

This advice looks sound. I'll definitely take it into consideration.

[-] DonjonMaister@programming.dev 1 points 1 year ago

I don’t like/use the class keyword in JS, because I quite like the paradigm with prototypes & stuff, and that keyword tries to make it fit into a totally different paradigm, which doesn’t really work IMHO.

I've read somewhere that Javascript is more of a prototype-oriented language rather than an object-oriented one. Do you agree with this?

BTW, I’ve developed a few strats to have my own style in TS that I like quite a lot. I can tell more if you’re interested.

Thank you! But maybe not right now; I'm still learning the basics. Have you considered write an article about it? 😮

[-] DonjonMaister@programming.dev 1 points 1 year ago

Fun fact: I made this meme to explain my classmates static variables.

[-] DonjonMaister@programming.dev 1 points 1 year ago

Hey, this looks pretty good. Thanks! 👍

[-] DonjonMaister@programming.dev 2 points 1 year ago

Yeah, I don't fully understand it either 😅.

[-] DonjonMaister@programming.dev 1 points 1 year ago* (last edited 1 year ago)

As long as you’re opting for composition over inheritance, it’s probably fine.

Totally agree with you there.

Probably on the “sparingly” end.

I'm on the same train of thought as you. I feel that relying too much on class ignores the better features that JavaScript has to offer. However, I'm sure that its application is useful on the occasion where inheritance IS (but very rarely) necessary.

[-] DonjonMaister@programming.dev 1 points 1 year ago

Yes. This seems to be one of the common arguments against "classes": they're not exactly classes in the traditional sense, and everything you can do in JavaScript can be done so without touching the class keyword. It's basically syntactic sugar that adds more confusion to the language, or so I heard. I've read this article that explains the flaws behind with this feature: https://www.toptal.com/javascript/es6-class-chaos-keeps-js-developer-up

[-] DonjonMaister@programming.dev 1 points 1 year ago

Thank you for the advice. Unfortunately I couldn't upload a .gif version; the website throws the following error: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data. I image that this could be the result of a file being too big (the .gif version is 5.27MB). So at the end I decided to upload the .mp4 version (799 KB).

[-] DonjonMaister@programming.dev 2 points 1 year ago

Applying the (DRY) Do Repeat Yourself principle.

view more: ‹ prev next ›

DonjonMaister

joined 1 year ago