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

If we could track copy-pasted chunks, then manual abstraction step would be needless, as it is already clear from editing history. We could then transform between abstract-nonabstract source or completely remove that distinction by making it view property. And modify one place and quickly update (or not) all others. We'll also have to deprecate 'modern' text sources and store code in structured way.

That should be all obvious to anyone with 10+ programming experience, imo, but I always see such "oh, dry or not, kiss or not" jitter. We now have great tools to do everything, except programming. Someone must make programming app better than just notepad-with-word-completion junk.



Ever heard of a function? If it's as simple as copy paste, that's all you need. The trickier abstractions come when you need something to be almost the same in two places. Copy and paste tracking wouldn't work there.

Replacing functions with some kind of copy paste tracking editor does not sound like an improvement.


Coverity actually has a really good tracking ability where it will find code that was copy/pasted/edited but the edit looks wrong.

I can't remember the name, but it will identify what it thinks is the original, and show where the copy/paste is, along with the edit it thinks was missing. This was usually around some error handling logic in our code base. Think:

    if (checkIsValid(foo)) {
      printf("Looks like foo is not valid.  foo == %s\n", foo);
    }
Wasn't uncommon for someone to copy that and forgot to change all places "foo" appeared.

Long story short, advanced static analysis has come a long way.


This is already solved on bigger scale -- RCS. You can develop, merge, blame, diff slightly different filesets, but not lineranges. Look, we already have both 'just functions' and dry-vs-complexity problem unsolved.


Static code analysis and a good IDE make this point considerably less important. For example, duplicating code is not nearly as expensive in my Spring (Java) application as it is in that shiny Nodejs webapp. It's still important, but solid tooling combats it somewhat.




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

Search: