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:
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.






I love it! I need this — now I just have to figure out how to get it into our standard developer PC build.
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
@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.
Awesome.
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?
@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
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)?
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…
@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.
As long as I can cut and paste that horribly long string into the dialog, it’s OK.