There was a question on StackOverflow the other day that perfectly illustrated the problem with doing something like that.Ĭobbling together a Frankenstein monster out of different code parts just can't be all that efficient. Going out and grabbing entire methods or systems to paste them into my project as-is and call it done is something I don't understand. It's not really my code, but I don't feel bad about using it in that scenario. Most times I retype the solution into my project (after all, it's probably written in the blog author's style, if nothing else). I find that the most frequent situation where I "cut & paste" code is when I have a particular problem and I run into a blog post that solves it. I know them and understand them by definition. Grabbing parts of my own work from my personal library is fair game. I'm going to talk about copy/pasting other people's code here. even if you don't refactor it yourself, it might become the difference between happiness and total frustration for the maintainer.Įventually, you'll end with good code in the end, even if you copy and paste. a docblock to remind yourself what to refactor and why. Nobody writes perfect code, even if it works, even when you are not copying & pasting and it is your own code, if you are not quite satisfied with it just put a note in comments (e.g. It can be debatable whether we should or shouldn't copy & paste code since the client/boss doesn't care (at least directly and in the short term) and you might end with the same results, but the problem really comes when it leads to bugs, loss of modularity, and ultimately, maintenance hell.
0 Comments
Leave a Reply. |