Skip to main content

Copy & paste based development

·481 words·3 mins
Programming
Alejandro Duarte
Author
Alejandro Duarte
Alejandro Duarte is a Software Engineer, published author, and award winner. He currently works for MariaDB plc as a Developer Relations Engineer. Starting his coding journey at 13 with BASIC on a rudimentary black screen, Alejandro quickly transitioned to C, C++, and Java during his academic years at the National University of Colombia. Relocating first to the UK and then to Finland, Alejandro deepened his involvement in the open-source community. He’s a recognized figure in Java circles, credited with articles and videos amassing millions of views, and presentations at international events.

Copy/paste keyboard

This is about Mr., W. J. a nice and friendly developer working for an IT company in a cosmopolitan city. He was in charge of five other developers. I was one of them.

It was probably my second day in the company, and he assigned a programming task to me. I was working on it, trying to figure out what the heck was that software I was going to help maintaining for the next months all about. Then, Mr. W. J. wanted to borrow my brain for a second. I wasn’t using it, so I lent it. “Do you think this is a good implementation?” Mr. W. J. puzzled asked while looking at the screen, then to my face, back to the screen, then to the infinite. “Ummm… I’d say…” I managed to merely bubble when he interrupted. “I think I can also do this…” he said and immediately started to select a whole class with a hundred lines of code or more. He copied the code. He pasted the code. He pasted it in an empty file, slightly changed the name of the class, and made some modifications in a couple of lines. He ran the application, tested something on the screen, and said “thanks” without any traces of irony.

I couldn’t resist my curiosity. “So… are you committing that code?” I puzzled asked while looking at the screen, then to his faceā€‹, back to the screen… “Yes!” he quickly replied without giving me the chance to look to the infinite. I thought it would be a Good Thingā„¢ to explain him that Copy & Paste Driven Developmentā„¢ is a Bad Thingā„¢ sometimes. Explaining to a junior developer why that technique should be avoided is not the same as explaining it to your manager*, so I decided to tell Mr. W. J. a story about copy & paste in software development.

“It’s funny,” I started saying. “Some years ago I was working in a company and did something like what you did,” I continued. “I copied a big portion of code, pasted it somewhere else and made a small adjustment,” I added. “I didn’t realise my boss was there when he poked me in my shoulder and said Ā«don’t do that againĀ»,” I convincingly finalised**. “Why did he say that?” Mr. W. J. puzzled asked while looking at the screen, then to my face, back to the screen. “I don’t know…” I defeatedly replied while looking at the screen, then to his face, back to the screen, then to the infinite…

* It highly depends on the manager and the junior developer in question.

** I switched roles while telling this short story to be more empathetic with Mr. W. J. Did you think I was a copy-paste maniac? I think Mr. W. J. was. I saw him copying and pasting identifiers that were 2 or 3 characters long sometimes.

Related

Semantic coupling
·474 words·3 mins
Programming
Code Complete is one of those books every developer should read.
Comments: A deodorant to mask code smells
·246 words·2 mins
Programming
Don’t get me wrong. Comments are useful and not all of them have the olfactory purpose of the famous analogy I’m using in this article’s title.
Lightning fast commenting (in and out)
·123 words·1 min
Programming
I have used this two or three times in my life but it’s one of those simple (and useful?