DRY? How about DROP?

The acronym DRY is popular with Rails folks, and maybe elsewhere. Don't Repeat Yourself. If you see two sections of your code doing essentially the same thing, create a single method which is called from those two places. Less code, less maintenance, better test coverage, less chance for errors later on. In database terminology, I'd talk about eliminating redundancy and avoiding update anomalies. It's the same thing. It's great advice, and clearly captures a bit of wisdom that (I'd venture to say) is applicable to most any kind of programming.

In addition to not repeating yourself, though, how about Don't Repeat Other People? Open source is all about scratching your own itch, so if you're driven to solve an old problem in a new way, go for it. But think first about why you're doing it.

Good software solves real problems. If the problem you're trying to solve is "how can I write something really cool?", I think that writing library code probably isn't the best answer. Instead, go build an app that really does something. Something YOU want to do. If you can't figure out what that is, I think THAT is the first problem you need to solve. When you start having hassles with the libraries that you're using, that might be the time to think about how you can make them better. But don't write the libraries first.

Does PHP really need another web framework cloned from Rails? Does Ruby really need another XML parsing library? Never say never, I guess, but I doubt it. If you want to work on something like that, it'd be a lot more productive to throw your talents into improving some existing project, rather than striking out on your own.

By all means, scratch your own itch. Just look around for a nice stick someone's left for you before you decide to invent a new yoga pose to do your scratching from. I sometimes feel like the Rails users put a little too much emphasis on novelty, and doing things in some new way, even when the old way really wasn't that bad to begin with. I think it's a desire born from very real and respectable foundations, like don't be constrained by old ways of doing things when you think you can do better. But, man, sometimes you can't do better. There's a lot of knowledge and practice in software which works pretty well, and it's usually ill advised to assume you're smarter. Bill and Ted said it all for me. "The only true wisdom comes in knowing that you know nothing." I dunno, maybe that was Socrates.

I say 'usually', because of course it's not always true. Sometimes people really do come up with better ideas, and we should be glad for those who are willing to say so. We should all be glad for the guy who will stand up and say the emperor has no clothes. But this can lead to a culture which values innovation for innovation's sake. It is bound to produce a bunch of sludge as well.

The problem is not that any of these things is inherently a bad idea. The problem is invention for invention's sake. This is the software equivalent of a fashion show, and it's just as pointless. Make something that does something new, not something that lets people do the same stuff in different syntax.

So, don't repeat yourself. But don't repeat others either. Find out what other code is out there which solve the problem you're working on. Help to improve that project. Talk about what it could do better. Don't spend your days toiling in isolation, reinventing everything under the sun.

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.