As Good As Dry

Ideally, each piece of information is stated OnceAndOnlyOnce, because its the system designer made it so you DontRepeatYourself (the titular DRY).

If you have duplication in code, the two can get out of sync. And they do. Often. Disastrously so.

On the other hand, there are cases where duplication is not so great a negative.

This example is typical of the LongTail of problems that you chase when you're trying to simulate true DRY, but still, at some point, it's AsGoodAsDry.

And I wonder how far this could go.

What if you noticed two areas of code that depended on a shared meaning:

in foo.rb

        obj.secret_code = 53

in bar.rb
        if 53 == obj.secret_code
          ...

Now, this is obviously pretty heinous programming to begin with. But if you came across it and weren't in a place where you could stop what you were doing and write tests then refactor? What if you had a mechanism like:

in foo.rb

# ConNascence with bar.rb
        obj.secret_code = 53

in bar.rb
        # ConNascence with foo.rb
        if 53 == obj.secret_code
          ...

Then you could have a tool, like a PreCommit check, verify that any blocks of code following such a tag would prompt you to verify the Evil Twin blocks have not been negatively impacted.

This isn't great, but is it AsGoodAsDry?


EditText of this page (last edited February 10, 2013) or FindPage with title or text search