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 28th, 2009 at 16:39 | #1

    I love it! I need this — now I just have to figure out how to get it into our standard developer PC build.

  2. March 28th, 2009 at 18:09 | #2

    I sincerely hope that this won’t be added on my machine! When I want to move code (re-order it) I Cut and Paste. When I create a private field I copy it and paste it when I want to use it. I found this approach sometimes to work faster for me then intellicense.

    I think you are trying to fix the problem in a wrong way, what about code analysis that can discover duplicate code? I bet that this would be a performance killer but some sort of reversed diff.

    -Mark

  3. March 29th, 2009 at 06:51 | #3

    @Mark: actually, I’m talking to the Visual Studio Development Team at Microsoft to see if they can add a similar feature to VS2011, and so far the idea is getting a great reception.

    I’ve also been working with them to remove the letter ‘Q’ from all reserved words and keywords in C#. It’s a shifty letter – rarely travels alone, and is it an O, or a 0, or what? Can’t trust it.

  4. March 30th, 2009 at 05:29 | #4

    Awesome.

  5. March 30th, 2009 at 08:59 | #5

    So wait, one shouldn’t copy and paste other people’s code. So you used the Clippy graphic from Microsoft Office? Whether or not this is a concept or a release version, it’s somewhat in the same vein, is it not?

  6. March 30th, 2009 at 09:16 | #6

    @Christopher Clippy’s not code, so it’s ok :)

    And, see not all copy/paste is bad – that’s why you’re not strictly forbidden to do it, you only need to affirm that you understand.

    In the release version from Microsoft, the affirmation textbox won’t allow you to copy/paste the oath in either :)

  7. March 30th, 2009 at 09:20 | #7

    This is an interesting concept, and I can see what it’s trying to do, but I think it could also be a big annoyance when you’re doing a “legitimate” copy/paste action. Could there be some way of making it more intelligent so that, for example, it could only alert you if the code you’re pasting already exists elsewhere (suggesting that you need to abstract to a method)?

  8. Greg
    March 30th, 2009 at 09:35 | #8

    you’d better be able to turn this off because there are times when nothing else will do — even re-factoring often involves the physical act of copying and pasting…

    In other words, I agree w/ Will A. above…

  9. March 30th, 2009 at 10:13 | #9

    @Will: yes, the official version from Microsoft will have this feature, I’m just providing them with a prototype. The goal is to make it nearly as intelligent as the original Clippy.

    @Greg: Hmm, good point – so In production, the AntiPaste plugin will have self-defense mechanisms built in – any attempt to remove or subvert AntiPaste will result in your system drive being formatted and a mean email being sent to your mother.

  10. March 30th, 2009 at 10:37 | #10

    As long as I can cut and paste that horribly long string into the dialog, it’s OK. ;)

Comment pages
Comments are closed.