Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Ada requiring the redundant name after "end" isn't a violation of DRY at all. The DRY principle is about the codebase as a whole, where repetition can lead to elements getting out of sync.

For example, instead of having an ORM define a mapping between classes and tables in, say, XML, DRY dictates that the mapping ought to be where it belongs, namely in the class declaration itself.

Ada's repetition is really more about readability. If you see an "end", you always knows what it matches. (Personally, I think it's useless.)



> Ada requiring the redundant name after "end" isn't a violation of DRY at all.

Yours is an arbitrarily narrow interpretation of the principle. To quote Dave Thomas, DRY states that

"Every piece of knowledge in the development of something should have a single representation."

The name of your function or block is one such piece.

I agree that having the compiler check the consistency of the redundant statements ameliorates the situation somewhat, but it would be better if the problem wasn't there at all.

[1] http://www.artima.com/intv/dry.html


The page you linked to directly refutes your claim of narrowness:

    Most people take DRY to mean you shouldn't duplicate code.
    That's not its intention. The idea behind DRY is far
    grander than that. [...] DRY says that every piece of
    system knowledge should have one authoritative,
    unambiguous representation
Note the terms knowledge and representation. He's referring to things like declarations, data models, schemas, facts. Duplicate source code symbols has nothing to do with it.

DRY is not "be terse". For example, turning a literal into a constant is DRY, because it reduces to a single "authorative, unambiguous representation". But "x = x + 1" (which certainly looks redundant) is not anti-DRY, nor is "end Foo;".




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: