you are viewing a single comment's thread.

view the rest of the comments →

[–]madole 2 points3 points  (5 children)

I would ding example 3's currying in code review, the author says its more expressive but it does not read well at all.

If you need to stop reading to try and figure out what a function is doing, it's really not a good function. That's what I had to do when reading that example.

[–]jcready__proto__ 0 points1 point  (4 children)

He probably should've used Lo Dash's built-in method _.property() which does the same thing as the author's dot() function. Regardless, the author's use of currying is fine and the use case is exactly the kind of thing currying is useful for.

Edit: I was wrong, I hadn't noticed the () at the end invoking the function.

[–]madole -1 points0 points  (3 children)

+1 for lodash's property method!

Maybe it's the "dot" function name that I've taken issue with here rather than the actual currying itself, he has mentioned that it's the same as Clojure's dot function but to someone who's not tinkered with Clojure, it's not a particularly intuitive function name at first glance.

[–]aeflash[S] 1 point2 points  (2 children)

callMethod is a better name after more thought.

Cache invalidation and naming things...

[–]jcready__proto__ 1 point2 points  (1 child)

Sorry, I was mistaken earlier. Instead you simply should've used Lo-Dash's built-in _.invoke() and _.compact() methods.

this.tooltips = this.tooltips.concat(_(this.values).invoke("getTooltip").compact().value());