Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Copy-and-paste programming
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Applying library code === Copying and pasting is also done by experienced programmers, who often have their own libraries of well tested, ready-to-use code snippets and generic [[algorithm]]s that are easily adapted to specific tasks.<ref>{{cite web|url=http://www.codeproject.com/KB/aspnet/dynamic_page_building.aspx?display=Print|title=Building ASP.NET Web Pages Dynamically in the Code-Behind|date=25 April 2008|publisher=codeproject.com|accessdate=2008-06-04}}</ref> Being a form of [[code duplication]], copy-and-paste programming has some intrinsic problems; such problems are exacerbated if the code doesn't preserve any semantic link between the source text and the copies. In this case, if changes are needed, time is wasted hunting for all the duplicate locations. (This can be partially mitigated if the original code and/or the copy are properly commented; however, even then the problem remains of making the same edits multiple times. Also, because code maintenance often omits updating the comments,<ref>{{cite web|url=http://www.informit.com/articles/article.aspx?p=457502|title=The Bad Code Spotter's Guide|publisher=InformIT.com|accessdate=2008-06-06|first=Diomidis|last=Spinellis}}</ref> comments describing where to find remote pieces of code are notorious for going out-of-date.) Adherents of [[object oriented]] methodologies further object to the "code library" use of copy and paste. Instead of making multiple mutated copies of a generic algorithm, an object oriented approach would [[Abstraction (computer science)|abstract]] the algorithm into a reusable [[Information hiding|encapsulated]] [[Class (computer science)|class]]. The class is written flexibly, with full support of [[Inheritance (object-oriented programming)|inheritance]] and [[Method overloading|overloading]], so that all calling code can be interfaced to use this generic code directly, rather than mutating the original.<ref>{{cite web|url=http://codebetter.com/blogs/raymond.lewallen/pages/59908.aspx|title=4 major principles of Object-Oriented Programming|publisher=codebetter.com|accessdate=2008-06-04|first=Raymond|last=Lewallen|archive-url=https://web.archive.org/web/20101125082900/http://codebetter.com/blogs/raymond.lewallen/pages/59908.aspx|archive-date=2010-11-25|url-status=dead}}</ref> As additional functionality is required, the library is extended (while retaining [[backward compatibility]]). This way, if the original algorithm has a bug to fix or can be improved, all software using it stands to benefit. [[Generic programming]] provides additional tools to create abstractions.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)