4 ms·
> Don't repeat yourself. (DRY) Beware the Share: http://programmer.97things.oreilly.com/wiki/index.php/Beware_the_Share http://programmer.97things.oreilly.com
by SideburnsOfDoom 12y ago
> Don't repeat yourself. (DRY)
Beware the Share: http://programmer.97things.oreilly.com/wiki/index.php/Beware_the_Share http://programmer.97things.oreilly.com/wiki/index.php/Beware...
It can bite you just as hard as DRY.
- lmm 12y agoReally? I've never seen that happen in today's days of, well, maven.
- SideburnsOfDoom 12y agoI don't know your language's tooling, but I don't think that the decision of when to share code or not - (i.e. if it actually represents the same concept) is something that is solved by a specific tool, or is limited to a specific language.
- lmm 12y agoI've never seen a problem that comes from code being shared, and I think that comes from maven getting the rules right: * Releases are immutable * Releases can only depend on releases * Releases can only be made when all tests pass. Twice. * The transitive dependency graph is a deterministic function of the config file; upstream changes cannot affect it * Dependency versions are only updated by an explicit manual step You never worry about "synchronizing" changes because other components can perfectly well depend on an old version of the library. You never accidentally break a downstream project, because everything's explicit. I have genuinely never seen the problems described in your link.
- SideburnsOfDoom 12y agoYou are talking about binary compatibility and immutable dependencies. That's nice, but it's a different topic to the conversation that jerf and I are having about the semantics of shared code. I'm sure maven is good at what it does, but it's not completely relevant.
- lmm 12y agoFine, then let me put it this way: your initial claim in no way matches my experience. "Beware the Share" is bad advice; that wiki page is simply wrong. Factoring out common code is a good thing and will not bite you.
- SideburnsOfDoom 12y agoIt's a wiki page, but it's also a book [1]. I have an actual paper copy, and I would highly recommend it. I've seen several of the authors give talks, most were good. Kevlin Henney (the Editor) was particularly so. However I shall also treat the data from your deep experience with all due reverence. 1] http://www.amazon.com/Things-Every-Programmer-Should-Know/dp/0596809484/ref=sr_1_1?ie=UTF8&qid=1424027969&sr=8-1&keywords=97+things+every+programmer+should+know http://www.amazon.com/Things-Every-Programmer-Should-Know/dp...
- jerf 12y agoThat's true, but my recommendation to newer programmers is still learn to practice radical DRY first, then as the final polish, learn when to back off (i.e., "the rule of three"). Far, far more programmers do not understand DRY, and accidentally avoid over-sharing by virtue of simply having bad coding practices in general and rewriting everything every time than overdo DRY. Someday I ought to write up a post about this sort of thing on my blog. I think part of our eternal warfare about coding practices (though by no means all of it) comes from the fact that there are different practices that should be followed by someone with two years of experience than someone with ten. For instance, I think test-driven development is great... for a new programmer. It is something that you will outgrow eventually. But in the meantime, TDD will teach you good design much more quickly than you would have learned any other way, and in the meantime, you'll produce better code than you would have otherwise just blundering around in the traditional manner. And for myself at coming up fast on 20 years of experience, I don't do "TDD" but I still do a lot of automated testing (and the damned code keeps surprising me, and punishing me whenever I think this time for sure I can skip the tests...). So too here with DRY; you may someday outgrow it, but you'll learn better design and programming skills in the meantime, and in the end I still think you'll find the optimum point is closer to DRY than farther from it. I think that's because beyond the surface gloss of DRY from a perspective of simply "not repeating code" you come to understand how a bit of code can embody a concept, and what DRY is really trying to teach you to avoid is having a concept live in two places, rather than raw code repetition, and that idea will stick with you until the end of your career. But to get to that level of understanding, practice radical DRY until you understand.