AntiPaste, because Pasting Code Is Harmful

March 28th, 2009

A while back I proposed the idea of a Visual Studio Add-In to discourage people from copying and pasting code.  The idea got such a **great** reception, I felt honor-bound to provide a proof of concept implementation so that the guys at JetBrains would have something to start off with, when they implement this into ReSharper. 

When you attempt to paste into the Editor, Clippy appears to ask you a question:

image

 

And he won’t let you continue the operation until you affirm that yes, you have considered alternatives, or to forget about it.

 

Code is up at Google Code SVN. I know you’ll love it.

Tony Rasa Esoterica

  1. March 30th, 2009 at 10:42 | #1

    @micsaund: don’t worry the production version will have that loophole removed ;)

  2. March 30th, 2009 at 12:13 | #2

    LMAO, I was just thinking about this on the drive into work today…

  3. Robert Höglund
    March 30th, 2009 at 12:31 | #3

    This is brilliant!

  4. April 7th, 2009 at 05:18 | #4

    This looks great, but as a colleague of mine has just pointed out, another thing to watch out for is when a developer makes a copy of the source directory for an entire DLL or EXE, renames it, and then adds it back into the solution. They then starts hacking away at it, almost as if a wizard just generated it for them.

    Maybe some kind of fuzzy comparison between projects would help here, to spot when they first add the new copy back into the solution.

    The dialog could say: “It looks like you’re trying to vandalize everything we hold dear.”

  5. April 7th, 2009 at 09:25 | #5

    @Daniel Heh an excellent idea for version 2 :)

  6. April 11th, 2009 at 00:33 | #6

    Anything that slows down the coder is bad. Work in progress often means moving code around. Refactoring sometimes means moving responsibilities (and related fields and functions) around different files. Personally I would find it insulting to have to write on what amounts to lines on a virtual blackboard.

    Peer reviews on check-in, occasional code reviews… that’s where to educate a developer by means of human communication about copying and pasting code. A mechanism like this is just asking to be gamed. If forced on someone it is the equivalent of a recurring nasty sarcastic note on your screen versus an honest constructive chat.

    I understand why you might want an automated nanny like that but if there must be something like this it should be a quality gate before check-in (like fxcop / stylecop) *not* something that criticizes the work as it is being written.

  7. April 11th, 2009 at 08:02 | #7

    @Paul It’s a joke. Lighten up.

  8. April 11th, 2009 at 08:12 | #8

    @Paul reading that terse comment, its way more harsh than i intended. oops. so here’s a free smiley :)

Comment pages
Comments are closed.