The Real Difference Between Copying Code and True Programming Mastery
Is copying and pasting code (with editing and adjusting it for different situations) a bad practice rather than writing it from scratch? If all you do is copy code, then the odds are...
Is copying and pasting code (with editing and adjusting it for different situations) a bad practice rather than writing it from scratch?
If all you do is copy code, then the odds are really good that you don't understand it as much as you think you do.
When you really understand code and can write it fluently, you can adjust what you write better to match the exact circumstances you're dealing with.
When you're fluent at writing code with one approach and you're exposed to a different approach, you can add the new technique as a new tool in your toolbox. Then as you write new code, you can decide which approach is best based on the specific needs of the function you're working on.
Now I've seen this from both sides. Professionally I'm a backend developer, but I frequently work on personal projects that need a frontend. Rather than learning React fluently, I've been copying and pasting of snippets to do what I need.
The difference is that I don't count myself as a React or Tailwind expert. I can use them, and I can see places that common controls should be refactored into their own control (which is honestly way better than some React code I've been handed), but I'm really not an expert at it.
Whereas when I'm working on the backend code that I create all the time, I rarely ever copy and paste code. I use docs constantly, since I don't have every API memorized, but when it comes time to create specific logic for the app, I just write the code.
And when I see copy-paste backend code, it often just looks wrong. It can be pretty obvious when code has been copied in and tweaked.
So it's not really that copying code that does what you need is necessarily bad. It's more that not really knowing how to program without copying code is bad.
Because people who really understand how to program find it faster to write the code than to search for and copy code.