Hacker News new | ask | show | jobs
by robomc 5351 days ago
Worth noting though that this can go too far the other way. I've definitely written things where, in my refusal to repeat myself, I've made a hard-to-read mess.

Here's an example from when I was very first starting out with ruby:

http://pastie.org/2749772

This is a pretty hard to read piece of code, despite my rambling comments. All done to avoid copying and pasting the same easy-to-follow method ~10 times.

1 comments

But the problem with this code isn't that there is too little duplication! The trouble wass that your grasp of the language wasn't that good and didn't have any idea of how to organize the code.
So, would you have solved it by a more readable form of metaprogramming? Seems to me it's either that, or copypasta.

(Could still be me being a noob, but I can't see some other architectural means of avoiding a choice between either duplication or tricky-to-read metaprogramming in that case.)