re: When do you create a function or method? VIEW POST

VIEW PARENT COMMENT VIEW FULL DISCUSSION

Alright. I understand now. Maybe I'm just too used to weakly typed languages. Thanks for the great examples!

Yes unfortunately in JS there is a preference to use lambda/ functions inside a public function, instead of declaring them outside, mainly because of the lack of language features (private functions ando/or modules support), but hopefully things will change in the next few years.

Anyway I don't normally bring JS in discussions about good/clean code because I haven't found yet a project or library that has one (in my oppinion). Even in large common libraries is custom to have 2-3 nested functions, 100LOC functions (random example Vue, createComponent function does at least 3-4 things, instead of 1), acute lack of defensive programming and other "bad practices".
PS: If you want to have nightmares go trough the NPM source.

I don't think large functions by themselves are really a problem. Large function that do way too many things without any structure or good flow could easily become a problem though.

Also, yeah, that createComponent function is difficult to understand... but maybe because I don't know much about VueJS

code of conduct - report abuse