dry

I like my martinis like I like my humor, like I like my application code:

DRY.

http://c2.com/cgi/wiki?DontRepeatYourself

but not too dry.

I read the gang of four design patterns book a while ago and I've been thinking about it a bit. Aside from the patterns, which are whatever, the actual premise of the book is really interesting, which is that these patterns come up again and again and again in software development.

That's difficult to reconcile with the DRY principle, or at least it admits defeat. It says, you will write this many times, so at least write it the same way each time, ok?

This is a little bit what I was trying to get at in the previous post; code reuse is a ruse. It almost never happens in the real world, at least not the way we want it to. As a programmer, I am chasing this fantasy that I will write a thing once, and then it will be Written, and I may Reuse it for the rest of my life.

But the fact is, code is actually easier to write than it is to read. So, six months from now when I've forgotten al the details of what I just wrote, I will happier to write it again than to try to understand what I wrote previously. Sad but true.

Taking that conclusion and applying it back to the DRY principle is interesting. It suggests limits on how seriously we should take the principle. I am actually a huge believer in DRY as a heuristic for class and module design. At a code level it makes a ton of sense. But over time, and over large teams, it breaks down. It may be worth repeating yourself, in order to avoid the hassle of creating a dependency. It may be worth repeating yourself, in order to create a new local version of the same knowledge. As broken as that sounds.

The result of making this compromise consciously is something in between code and data. "Script" is the closest word for it. I've been thinking a lot about the continuum of art-design-code-system-hardware, and it's interesting to me how different people gravitate to different points on the scale.

The people who live over on the right have a bad attitude, in my opinion, towards anyone to the left of them. I get to say that because I could be one of them, if I wanted to. So I tell myself.

No comments:

Post a Comment