296
you are viewing a single comment's thread
view the rest of the comments
[-] lemmesay@discuss.tchncs.de 9 points 1 year ago

I oscillate between using more functional paradigms and more object-oriented ones. is that normal?
I use a linter BTW(TypeScript) if that is a useful info.

[-] jkrtn@lemmy.ml 9 points 1 year ago

I think using both is normal. Closures and objects are duals of each other. Do whatever is understandable and maintainable, neither paradigm is magic.

[-] lemmesay@discuss.tchncs.de 4 points 1 year ago

that's a nice way to look at it. thanks!

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

Is the duality statement meant to be true in a technical sense?

[-] jkrtn@lemmy.ml 1 points 1 year ago

Yeah! For example, if the language allows closures to capture state, they can act like properties on an instance.

[-] kogasa@programming.dev 1 points 1 year ago
[-] jendrik@discuss.tchncs.de 1 points 1 year ago

A closure is a function with captured state. An object is state with methods.

[-] crispy_kilt@feddit.de 3 points 1 year ago

Avoid shared mutable state like the plague in any paradigm and you'll be fine

[-] lemmesay@discuss.tchncs.de 2 points 1 year ago

state management crying in the corner

[-] crispy_kilt@feddit.de 2 points 1 year ago

Functional state management is fine

[-] ZILtoid1991@lemmy.world 3 points 1 year ago

I also do that. Very simple stuff, especially of those that are easy to optimize for the compiler, are often very close to functional programming paradigms.

[-] DickFiasco@lemm.ee 2 points 1 year ago

I use a combination of both. Objects are declared const, all members are set in the constructor, all methods are const. It doesn't really work for some types of programs (e.g. GUIs) but for stuff like number crunching it's great.

[-] lemmesay@discuss.tchncs.de 2 points 1 year ago

I heavily use classes while working on back end, and when I'm making a really self-contained logic, such as a logger or an image manipulation service.
but since most frontend stuff heavily leans on functional side, I go with it

this post was submitted on 21 Mar 2024
296 points (94.8% liked)

Programmer Humor

24206 readers
573 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS