Code reuse: Difference between revisions

Content deleted Content added
Undid revision 1068606950 by Alexander Davronov (talk) Do not restore nonsense to articles
Tags: Undo Reverted references removed
Reverting edit(s) by 82.132.213.165 (talk) to rev. 1068606950 by Alexander Davronov: non-constructive (RW 16.1)
Tags: RW Undo Reverted nowiki added
Line 1:
'''Code reuse''', also called '''software reuse''', is the use of existing [[software]], or software knowledge, to build new software,<ref>{{cite journal |last=Frakes |first=W.B. |author2=Kyo Kang |s2cid=14561810 |date=July 2005 |title=Software Reuse Research: Status and Future |journal=IEEE Transactions on Software Engineering |volume=31 |issue=7 |pages=529–536 |doi=10.1109/TSE.2005.85 |citeseerx=10.1.1.75.635 }}</ref><ref name="Reddy2011" >{{Cite book|last=Reddy|first=Martin|url=https://www.worldcat.org/oclc/704559821|title=API design for C++|date=2011|publisher=Morgan Kaufmann|isbn=978-0-12-385004-1|___location=Boston|oclc=704559821}}</ref>{{Rp|page=7}} following the [[reusability|reusability principles]].
{{tone|date=January 2022}}
 
'''Code reuse''', also called '''software reuse''', is the use of existing [[software]], or software knowledge, to build new software,<ref>{{cite journal |last=Frakes |first=W.B. |author2=Kyo Kang |s2cid=14561810 |date=July 2005 |title=Software Reuse Research: Status and Future |journal=IEEE Transactions on Software Engineering |volume=31 |issue=7 |pages=529–536 |doi=10.1109/TSE.2005.85 |citeseerx=10.1.1.75.635 }}</ref> following the [[reusability|reusability principles]].
Code reuse may be achieved by different ways dependending on a complexity of a programming language chosen and range from a lower-level approaches like code copy-pasting (e.g. via [[Snippet (programming)|snippets]]),<ref>{{Cite journal|last=Selaolo|first=Karabo|last2=Hlomani|first2=Hlomani|date=2016|title=Towards An Algorithms Ontology Cluster: for Modular Code Reuse and Polyglot Programming|url=https://www.researchgate.net/publication/305144699_Towards_An_Algorithms_Ontology_Cluster_for_Modular_Code_Reuse_and_Polyglot_Programming|journal=Advances in Computer Science|volume=5|pages=63|via=Researchgate}}</ref> simple functions ([[Procedure (computer science)|procedure]]<nowiki/>s or [[subroutine]]<nowiki/>s) or a bunch of objects or functions organized into [[Modular programming|module]]<nowiki/>s (e.g. [[Library (computing)|libraries]])<ref>{{Cite web|title=4. Code Reuse: Functions and Modules - Head First Python, 2nd Edition [Book]|url=https://www.oreilly.com/library/view/head-first-python/9781491919521/ch04.html|access-date=2022-01-26|website=www.oreilly.com|language=en}}</ref>{{r|Reddy2011|page=7|}} or custom namespaces, and [[Package manager|package]]<nowiki/>s, [[Framework (computer science)|framework]]<nowiki/>s or [[software suite]]<nowiki/>s in higher-levels.
 
Code reuse implies dependencies which can make [[Maintainability|code maintanability]] harder. At least one study found that code reuse reduces [[technical debt]].<ref>{{Cite journal|last=Feitosa|first=Daniel|last2=Ampatzoglou|first2=Apostolos|last3=Gkortzis|first3=Antonios|last4=Bibi|first4=Stamatia|last5=Chatzigeorgiou|first5=Alexander|date=September 2020|title=CODE reuse in practice: Benefiting or harming technical debt|url=https://linkinghub.elsevier.com/retrieve/pii/S0164121220300960|journal=Journal of Systems and Software|language=en|volume=167|pages=110618|doi=10.1016/j.jss.2020.110618}}</ref>
 
==Overview==
Line 6 ⟶ 9:
[[Ad hoc]] code reuse has been practiced from the earliest days of [[computer programming|programming]]. Programmers have always reused sections of code, templates, functions, and procedures. Software reuse as a recognized area of study in software engineering, however, dates only from 1968 when [[Douglas McIlroy]] of [[Bell Labs|Bell Laboratories]] proposed basing the software industry on reusable components.
 
Code reuse aims to save time and resources and reduce [[Redundancy (information theory)|redundancy]] by taking advantage of assets that have already been created in some form within the software product development process.<ref>{{cite web|author1=Lombard Hill Group|title=What Is Software Reuse?|url=http://lombardhill.com/what_reuse.htm|website=lombardhill.com|publisher=Lombard Hill Group|accessdate=22 October 2014|archive-date=23 January 2019|archive-url=https://web.archive.org/web/20190123223128/http://lombardhill.com/What_Reuse.htm|url-status=dead}}</ref> The key idea in reuse is that parts of a [[computer program]] written at one time can be or should be used in the construction of other programs written at a later time.
 
Code reuse may imply the creation of a separately maintained version of the reusable assets. While code is the most common resource selected for reuse, other assets generated during the development cycle may offer opportunities for reuse: software components, test suites, designs, documentation, and so on.<ref>{{cite web|author1=Lombard Hill Group|title=What Is Software Reuse?|url=http://lombardhill.com/what_reuse.htm|accessdate=22 October 2014|archive-date=23 January 2019|archive-url=https://web.archive.org/web/20190123223128/http://lombardhill.com/What_Reuse.htm|url-status=dead}}</ref>
Line 25 ⟶ 28:
Concerning motivation and driving factors, reuse can be:
* Opportunistic – While getting ready to begin a project, the team realizes that there are existing components that they can reuse.
* Planned – A team strategically designs components so that they will'll be reusable in future projects.
 
Reuse can be categorized further:
Line 36 ⟶ 39:
* Forked – The client code contains a local or private copy of the reused code, and thus they share a single life cycle and a single version.
 
Fork-reuse is often discouraged because it is's a form of code duplication, which requires that every bug is corrected in each copy, and enhancements made to reused code need to be manually merged in every copy or they become out-of-date. However, fork-reuse can have benefits such as isolation, flexibility to change the reused code, easier packaging, deployment and version management.<ref name="sharednow.blogspot.com"/>
 
==Systematic==