cargo cult programmer
is a person who takes the sample code as the work of a diety, not to be understood and changed but to sit, inviolate, in the code base.In contrast,
copy-and-paste programming
is taking a solution for one case and copying it, pasting it, making a small change for the next case, and so on. If there's one line of change in a 20-line copied chunk, this means that there are 19 lines that are duplicated, and if there's a problem, 19 lines that have to be serially debugged and fixed wherever you left them, and you might easily forget many of them. It's better to pull as much as you can to a subroutine so if there's a bug, there is one and only one place you have to go to fix it.Clearly, two anti-patterns you should try to avoid in your programming life, to be sure, but if you copy code from a website and paste it into your own program, you are not a copy-and-paste programmer. Please respect the distinction.
No comments:
Post a Comment