DEV Community

Discussion on: Code Smell 21 - Anonymous Functions Abusers

 
netch80 profile image
Valentin Nechayev

Why is the opposite?

"Wrong" code in your post is, except naming, is definitely better than "right" code. The only aspect to correct is naming, as already said in another comments (and Iʼd doubt whether naming was spoiled unintentionally).

Do you have a better example?

Should I? Itʼs your goal to show the initial thesis by good examples. But, to cast a seed for discussion, a better example would show
1) effect of passing an unknown function through multiple execution levels and possibly stored in a data structure (and reused much later on),
2) consequence of absence of traceable function origin (and, what is important, just function name isn't enough).

Thread Thread
 
mcsee profile image
Maxi Contieri

IMHO "Wrong" code is more cryptic and less declarative

Even it might seem more compact it is programmed like the 50s

On the contrary, "Right" code is higher level, more reusable and more declarative

Thread Thread
 
redbar0n profile image
Magne

I respectfully disagree, and can only refer you to my first comment for my reasoning, in case you overlooked it.