siiky
2021/12/15
2022/07/07
en
Naming, using, reading, and understanding well named operations rather than (kinda) well named variables grows the habit of reading and understanding code rather than relying on variables being well named -- and everyone knows naming is hard.
Bad:
x = '42' x_food = foo(x) x_bard_food = bar(x_food) x_zazd_bard_food = zaz(x_bard_food)
Good (using procedural composition):
x = zaz(bar(foo('42')))
Better (if the chain of operations is long):
x = '42' x = foo(x) x = bar(x) x = zaz(x)
Best (using functional composition):
(=> '42' foo bar zaz) ; OR ((-> foo bar zaz) '42')
It also comes with rather nice advantages. Just compare the two approaches in each scenario:
And a final bonus: the "better" approach is easier to read than the "bad" approach, and requires less typing, thank you very much.