r/Clojure • u/cntx • Oct 02 '15
Writing friendlier Clojure
http://adambard.com/blog/write-friendlier-clojure/5
3
u/CurtainDog Oct 03 '15
It's hard. I still don't like in the final refactoring that Markov data calls make Markov mapping calls sentence to word list. That kind of nesting suggests a failure of composition (or perhaps composability).
The core issue in my opinion is that core clojure lacks a good data structure to represent the processed text. If we had a weighted directed graph to represent the data then the functions would fall out more naturally.
0
Oct 02 '15
[deleted]
2
u/TweetsInCommentsBot Oct 02 '15
Example of refactoring Clojure, extracting into functions, using threading ops (collection pipelines) by @adambard
This message was created by a bot
14
u/[deleted] Oct 02 '15
I'm very happy to see a post like this! I've been waiting for one for a long time.
As counter-intuitive as it is, I think it's a problem in the Clojure community that it's made up of a lot of smart people. Their biggest flaw being that they're too smart to fail to understand their own spaghetti. Failing to see that two months down the line, when they (or a coworker) needs to fix a "small" bug, it'll take them three times longer for no reason.
This is how legacy code is written.
Java might be verbose (and believe me, I'm not a fan either) but they got something right with the emphasis on design patterns and clean code. We could all learn from that.
Programming is a social endeavor. Even if you are the only person who reads your code. Ever wrote a function to, six months later, not understand a single thing about it? Ever read a function by a coworker and wondered WTF he was thinking?
Writing a function that is more than 20 lines long is rude. We should all be mindful of that.
OP, keep em coming :)