Re:2 is a code smell
by humbledrone on Wednesday October 12, 2011 @02:13PM
(#3103808)
The final (varargs) add-vectors function in the OP is clearly (at least to me) more terse and readable than the original (2 arg) one. I've only written a couple thousand lines of Clojure to date, but code like that already just looks right. The varargs version has less possibilities for errors; the 2 arg version allows for several permutations of first/second to be written incorrectly, or the wrong va/vb used.
I do think the author has a point, but to me the logical complexity progression for a piece of code is:
1. Make it work in the "1" case.
2. If necessary, make it work in the "2" case.
3. If necessary, make it work in the "n" case (n variable).
I find this particularly useful for larger decisions: I can make this work right now if I add this tiny little wart? No problem. Another thing came up and a similar wart is required? Ok, I guess. A third? Time to find the structure that my code is telling me about and refactor to expose it.