Clipboard Oriented Programming?


I have come to discover a new approach to software development. I have to admit, I find it very concerning, and more than a little dangerous. For want of a better term, I am going to call it Clipboard Oriented Programming. Let's define COP as the abuse of copy and paste to create new software, rather than writing the code yourself.


Now the general gist of this approach is to use copy and paste as your primary approach to creating new software. This can be something as seemingly innocuous as "hey this function is just like what we did in a different module, but some things are changed. Lets copy that function, and just change the parts that apply to our module." Other times, it will be more involved, and even more dangerous. I have actually been in conversations where the start of the project was a discussion of what code-base to copy and paste. Neither of these is what I would consider a craftsman-like approach to creating software.


So, what's wrong with using the tools that you have, and building off good work already done? Nothing. Nothing at all, as long as it makes sense, and doesn't cause quality to suffer. But that isn't what COP is. It may start out harmlessly, but it becomes an addiction, and all of a sudden we end up with unmanageable code. Lets explore some of the problems, with COP, and perhaps we can see some alternatives.



The first case, where we see a similar problem that has already been solved. We see the code that does some thing, say a creating a particular service endpoint. What almost invariably happens is that once the code is copied, the number of changes to the pasted code is close to or greater than the amount of effort it would have taken to just write it from scratch. The process of writing it from scratch, especially if you are practicing TDD, may lead you to a better solution. Or, maybe, if someone else has already solved this problem, rather than copy their solution, use it. Make a call to that function, or instantiate that class. If there are things we need to modify, then our instinct should be to extend the existing construct, not just copy it and change the things that are different. We have the tools to do this, we just need to stop and think it through first, rather than default to the "easy" answer.


How about another case? We have a new project, and we have no clue how to start. Maybe its a new technology we've never used before. These days, most people start by searching the internet for ideas. Maybe we check out Stack Overflow. Once we find what we are looking for, we are ready to start implementing. We can create a spike where we experiment with the techniques, libraries, etc. that are recommended. Once we have a good feel, like any spike, we revert the code and then write the real thing in a test driven manner. You know what we don't do? We don't copy the code from the internet and paste it into our project, then try to tweak it to our needs. At the Rocky Mountain Programmers Guild our Master Craftsman, Joe, called this approach the "Full Stack Overflow Developer". The code that this anonymous person wrote on the internet has no awareness of your needs, your implementation, or even your problem domain. That isn't to say they don't have good ideas. Learn from those ideas and then make your own software. My experience has been that every time I've worked with a team who did this, they ended up down several rabbit holes before finally giving up.


OK, why does this bother me so much? What is it about this approach that is so dangerous? It

goes way beyond just the fact that duplicating code is duplicating bugs. When we look at the Craft, we are seeing a willingness to accept second best just in the pursuit of an illusory saving of time. Software is bespoke. Every solution is different, and specific to the need that it is designed to address. As professionals, we are always learning and growing. Copying somebody else's code doesn't help us become great at what we do. We need to embrace our Craft. Our customers engage us because they trust us to do the best possible job making their software. If all we are going to do is copy from Someone Else, maybe they should look for Someone Else to do the job.


55 views0 comments

Recent Posts

See All