Dani Kim Blog

Copy & Paste


The API of You

I copy and paste code all the time. Especially chunks of code (that are meant to be copied and pasted) or when I am declaring dependencies on my web application. Code, to an extent, is meant to be reused. The problem arises when I copy and paste code that I do not fully understand line-by-line. I have always been discouraged to copy code, not too frequently at least. If I have to rely on copied code, that means that I do not know the syntax nor the logic well enough. With this ideology in mind, for two weeks, I logged every time I used the copy (Cmd + C) and paste (Cmd + V) commands on my computer. Using a Mac OS X Keylogger, below is the data set that I tracked.
Copy (keyCode == 55 and keyCode == 8)
Paste (keyCode == 55 and keyCode == 9)
Successful Copy and Paste (element == "Paste" and lastElement == "Copy")
"Successful Copy and Paste" is when the copy command is immediately succeeded by the paste command. In addition, the Unix timestamp is logged with every keylog, which is parsed to legible (MM-DD-YYYY) time. See below for the raw data collected. The objectives of this project was 1) to track the number of times that I copy and paste code, purely out of curiosity, 2) to visualize the data in an impactful way, and 3) to be able to compare my copying and pasting behaviors with other developers working on the same project.
The limitations were that 1) because every user had different copying and pasting behaviors, the figures returned were not indicative of a "good" or "bad" habit. Nonetheless, the can be used to illustrate a user's key logging patterns. 2) The data was not limited to only code. 3) After analyzing the raw data, I realized that many times I do not release the Command key while I transition from copy to paste. Intricacies like there are something that I will need to consider on the next iteration, if any. 4) Lastly, there was no way the parsed data from the Keylogger automatically got pushed to my database.
For potential next steps, I would be intrigued to explore what kind of data I am actually copying and pasting. Our computers temporarily save our most recently copied data onto our local clipboard. Logging that data, I wonder what kind of trends or insights I could discover from the details of my copying behavior.