Editor’s note: I think this falls under the heading of ‘conventional wisdom.’ In addition, I’m walking a fine line between ‘self-help’ and ‘beating a dead horse.’ Perhaps poorly. Bear with me.
I do a lot of programming. Sometimes I do it for work, sometimes I do it for fun, but all in all I’m looking at code for about 75% of my waking hours. If there’s one thing that guides developers in their work, it’s this almighty principal:
Don’t Repeat Yourself.
DRY, as it’s often abbreviated, is something that transcends every coding language, every discipline, and every project. I’d wager it’s the best way to gauge a developer’s skill: how well does he/she handle repetitive tasks? I’d place my observations of really good programmers close to the realm of religious experience; the code they write is efficient, extensible, and most impressive of all, elegant.
I find myself doing a lot of repeating. I feel guilty every time I have to slog through a repetitive task because I lack the knowledge to attain the almighty DRY. But today, writing out a piece of code that I’ve probably written 100 times prior, I figured I’d take a time out to consider the pros and cons of repetition. And at the end of it, I really wanted to make a point. That point:
Don’t Repeat Yourself.
Because repeating yourself is the best way to learn how things work. I think the drive to avoid repetition minimizes the fact that repetition creates opportunities for improvement. Obviously, there are different types of repetition, and DRY still reigns almighty in the code I write, but the point stands: Repeat yourself often. Do things twice. Finish a task, then start from scratch. Practice.