Talk:Copy-and-paste programming

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Expanded, organized, referenced[edit]

I have expanded this section's discussion of copy and paste programming by experienced programmers, and rather than having it as one continuous block of uninterrupted text, I've rearranged much of the text to create two distinct major sections. Also, I have added a number of references. I believe this article now qualifies for removal of the "no references" designation, as well as the "stub" designation. Rnickel (talk) 16:43, 5 June 2008 (UTC)[reply]

sweeping changes[edit]

While the Perl Design Patterns Books is a great resource, this article reproduced from it is not encyclopaedic. The article is very well written and well suited for a book on Perl Design Patterns, but it's next to useless as an encyclopaedia entry on a programming phenomenon. A fine example of cut and paste article writing!

I have replaced the article with a basic start on actually describing cut and paste programming, rather the in depth discussion of why it it's wrong to do it in Perl (which is what this article used to be).

???[edit]

oi! I like package Util. where else do you stick stalwarts like MakeStringBlankIfNull() and AddPI() ??

this page contains too many perl specific references. the code examples should be rewritten in pseudo-code and the perl package references should be dropped

Still wrong?[edit]

"However, adherents of object oriented methodologies claim that this form of programming is still wrong."

It may be wrong and that all code should be always completely different from something else, but most languages have certain things built into them that force you to use the same line of code as a previous situation, such as: public void actionPerformed(ActionEvent e)

You cannot avoid writing this line of code in Java in certain situations. 2 cents.

also known as: "bug & Paste" or "copy bug"

merge recommendation[edit]

Recommend Plug and Play modding content be merged into this article, provided adequate referencing is provided. Doesn't seem to be a distinctive enough practice for its own article Bwithh Join Up! See the World! 03:52, 11 February 2007 (UTC)[reply]

The article was deleted via proposed deletion for lack of such adequate referencing. Rigadoun (talk) 19:35, 12 December 2007 (UTC)[reply]

I give up; what does "in conjecture with" mean?[edit]

That's in the first paragraph (the first two lines of the abstract). Better yet, what is it supposed to mean? —The preceding unsigned comment was added by 60.234.168.92 (talk) 01:13, 13 March 2007 (UTC).[reply]

I tried to remove bias[edit]

This article still seems strongly slanted against copying and pasting, ever, in programming. I've tried to remove some of that bias. Mathiastck 23:32, 23 May 2007 (UTC)[reply]

Neutrality[edit]

I agree that "It is a common mistake of the inexperienced or lazy programmer to duplicate code instead of writing a set of methods or objects", but unfortunately, this statement is obviously heavily biased and unattributed, and hence a violation of Wikipedia's "Neutral Point of View". My approach, when I did the reorganization of this article, was simply to dispassionately describe the problematic programming practices in the "Forms" section, and then to address the difficulties they create, with references, in the "Effects" section.

The fact that there has already been a change of "looping" to "set of methods or objects" is absolutely indicitive of the problem: there is no one single solution to bad programming. The general antidote is good decomposition, but what that will look like depends entirely on the programming methodology being used: procedural models will take a different approach than object oriented models for example. Rnickel (talk) 16:43, 22 July 2008 (UTC)[reply]

Loop unrolling etc[edit]

I reverted the good-faith edits made by 95.199.24.203 due to a number of problems with tone and sourcing:

  • The tone was non-encyclopedic; it sounded conversational and read more like personal opinion.
  • There were no sources for any of the statements; a number of them appeared to be original research.
  • There were several grammatical errors.

I did preserve the mention of loop unrolling, since that seemed to me to be the most significant point raised. There could be further discussion of loop unrolling in the body of the article, although the statement that it is "a common practice to gain speed increase on modern computers" is egregiously untrue. In fact, manual loop unrolling has become all but extinct in the modern era as improvements in compiler technology have removed the need for programmers to pursue these types of "speed hacks". --Rnickel (talk) 17:33, 30 July 2013 (UTC)[reply]

Writing swap by hand is common? Where exactly?[edit]

The paragraph http://en.wikipedia.org/wiki/Copy_and_paste_programming#Example claims that

"While this can be abstracted into a macro or a function, this adds considerable overhead and reduces readability of the code (see snippet example), as this is a common idiom."

This needs citation, and it is not true. In the C++ community, for example, it is common to use the std::swap-function. Even more, when writing classes, it is common to provide non-throwing swap functions. Even more more, std::swap is assumed to not throw and used as the foundation for enabling exception save code.

Handwriting swap is totally counterproductive in C++ and textbook saying you should handwrite should be thrown away.

  • It is less readable than the word "swap"
  • It opens loopholes in a program's exception safetyness
  • It comes at a performance cost because the manual version uses an additional copy of the complete datastructure (think in Megabytes or more), where under the swap-API only the interal pointers have to be swapped

Phresnel (talk) 15:22, 20 August 2013 (UTC)[reply]

Update[edit]

I replaced the example with a more neutral one. Should the original author of that uncited claim by uncomfortable with my change, then she/he may please use citations to prove that manually writing swaps is common, because for at least a huge subset of the programmer folks, it isn't ( http://langpop.com/#normalized ).


Phresnel (talk) 15:35, 20 August 2013 (UTC)[reply]

Gif animation[edit]

I've made a simple animation to show one of the problems of C&P programming: when original code block contains error, all copypasted blocks will contain this error too and the fixing the bug will not be a trivial task (in gif programmer accidentally forgot to change some code blocks). Do you have any notes for animation? Do you have any objections not to include animation to article? Waitnig for feedback. --Atroshko (talk) 06:54, 7 December 2013 (UTC)[reply]

POV issues[edit]

This article contains express terms connecting "copy-paste" and "snippet" usage as indications of inexperience or lack of proficiency in programming and editing operations. This position is not substantiated by any citations, and it also seems to ignore that experienced and highly proficient programmers use such methods as a simple means of saving keystrokes and reducing the risk of repetitive strain and other occupational hazards experienced routinely by professional programmers.

Moreover, this position seems to ignore the obvious fact that *most* professional-grade editors and IDEs contain support for some kind of abbreviation or snippet management, precisely because there is demand for this among programmers and other professionals who do not wish to manually type boilerplate and needlessly repetitive data entry.

dr.ef.tymac (talk) 15:32, 30 May 2014 (UTC)[reply]

While I was reading this article, I kept thinking of a couple of projects I was working on in C using X Windows on Unix in the early 1990s. For the user interface, the first two things I wrote a generalized string input routine, and the second thing was a generalized menu routine (that would read the menu from a text file, so you could change the menu without recompiling the program). I spent the best part of a year cheerfully plugging those two routines into well over a dozen programs on several wholly different projects and it saved me whole bunches of time. JHobson3 (talk) 17:11, 18 August 2016 (UTC)[reply]

External links modified[edit]

Hello fellow Wikipedians,

I have just added archive links to one external link on Copy and paste programming. Please take a moment to review my edit. If necessary, add {{cbignore}} after the link to keep me from modifying it. Alternatively, you can add {{nobots|deny=InternetArchiveBot}} to keep me off the page altogether. I made the following changes:

When you have finished reviewing my changes, please set the checked parameter below to true to let others know.

This message was posted before February 2018. After February 2018, "External links modified" talk page sections are no longer generated or monitored by InternetArchiveBot. No special action is required regarding these talk page notices, other than regular verification using the archive tool instructions below. Editors have permission to delete these "External links modified" talk page sections if they want to de-clutter talk pages, but see the RfC before doing mass systematic removals. This message is updated dynamically through the template {{source check}} (last update: 18 January 2022).

  • If you have discovered URLs which were erroneously considered dead by the bot, you can report them with this tool.
  • If you found an error with any archives or the URLs themselves, you can fix them with this tool.

Cheers. —cyberbot IITalk to my owner:Online 13:05, 17 October 2015 (UTC)[reply]

Testing[edit]

Unit test code is an example where copy-and-paste programming may be acceptable. Could cite https://mtlynch.io/good-developers-bad-tests/ as a source, if deemed reliable enough. Syneil (talk) 09:20, 17 March 2021 (UTC)[reply]