After recently taking a break from a project that my development team put a lot of time and effort into, coming back to it after another team worked on it has left me uneasy. Dedicating so much time to building a structure for other developers to build on is a pride that can only be beaten out of an individual by lazy programming.
When having a conversation with my team, we were quick to blame the ‘copy and paste coding culture‘. When we really got into the chat though, I think we found the root cause for the problem. We think that the problem is developers who don’t stop to think about what they might be doing before they do it.
Some of you may be thinking, “I copy and paste all the time!”, but in my view, copy and paste without thought promotes bad coding habits when it comes to designing a well structured application.
In many of the situations where I’ve seen blatant copy and paste without though is when developers are trying to get code to work in another area of a project that isn’t currently accessible. I put to those developers, instead of just copying the code, stop and think about moving the code into a common area where it can be accessed by both the original and the new locations. This reduces code duplication and means if there is a bug found in the code, you only have to fix it in one place!
Also, as you probably already work with a team of other developers, why not just stop to ask someone. In most cases, you’re most likely working with the developers who have created or modified the code you’re working on previously.
If you were a developer in my team, I’d always be welcoming and give the time to help you improve as a developer by helping you to understand the project’s code. The reason not being one of self pride but because it not only benefits you to learn the code but it helps the development of the project and team involved in it so there isn’t a code clean up effort down the line.
To end this opinion, I want to clarify that copy and paste is not always a bad thing. While the idea of a programmer copying and pasting code can come across as lazy and having a lack of experience, there are often times that it can be a good idea to copy code.
Think of a code snippet that you’ve found online that provides a starting point for you to work from. It seems like a valid situation where copy and paste is good for programming, right? If the snippet is well documented and you can understand it completely, why would you write it from the ground up yourself?
But the main point in all of this is for you to just stop and think about what you’re doing. It may seem like time and effort to take 10 minutes of your own time to think about what you’re doing but it can save hours (if not days or weeks) of technical debt that you could end up adding to a project.
As a next preventable step as a technical lead on a project, I would highly recommend enforcing code reviews within your development team on a regular basis to embed a new habit amongst your developers where you’re all looking at each others code to understand the how and why of the implementations.
I’ll now recede back into the nightmare that is before me and help to reduce the team project’s technical debt…