3 ms·
Please don't do this. It might be clever, and it's the sort of thing that would be pretty cool to include in a CS lecture about higher-order functions, but it
by peterkelly 9y ago
Please don't do this.
It might be clever, and it's the sort of thing that would be pretty cool to include in a CS lecture about higher-order functions, but it won't earn you the gratitude of fellow team members who have to maintain your code after you leave.
- MichaelApproved 9y agoYup. If someone has to spend 30 minutes trying to understand one line of code, you're doing it wrong. I'll take 10 lines of code that clearly self documents with elaborately named variables over this 1 line of magic.
- konschubert 9y agoCode should not be clever. Good code is straight forward, carries no surprises and makes the whole task at hand look easy.
- jonny_eh 9y agoClever is ok if it's still understandable or is needed to be clever to get the job done.
- danieltillett 9y agoI would not go this far - writing code like this is fun. What you should never do is use code like this in anything important.
- ocharles 9y agoImportant code has a way of starting out unimportant.
- danieltillett 9y agoThis is true, but including code like this should make it easier to know you should rewrite if you are going to use it in something important. I have been bitten more often by quick hack code that looks OK on the surface than code that is full of clever code like this.
- blktiger 9y agoI could _maybe_ see this code ending up in production code where performance optimization matters (if it actually fixes a performance issue). But if you did that you had better put a comment next to it clearly explaining why you had to do that for optimization purposes and how it works.
- zebraflask 9y agoAgreed. Cool find, though. Clever =/= robust or reliable, many times, and that's what they pay us the bucks for.