Content deleted Content added
m Protected "Code reuse": Persistent sock puppetry ([Edit=Require autoconfirmed or confirmed access] (expires 12:43, 30 April 2022 (UTC))) |
m →Types of reuse: HTTP to HTTPS for Blogspot |
||
(35 intermediate revisions by 23 users not shown) | |||
Line 1:
{{Short description|Using existing code in new software}}
'''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]].▼
▲'''Code reuse'''
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]]s or [[subroutine]]s) or a bunch of objects or functions organized into [[Modular programming|module]]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]]s, [[Framework (computer science)|framework]]s or [[software suite]]s in higher-levels.▼
▲Code reuse may be achieved
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>▼
Code reuse implies dependencies which can make [[Software maintenance|code maintainability]] harder.{{Citation needed|date=February 2023}}
▲
==Overview==
{{
[[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.
The [[Library (computing)|software library]] is a good example of code reuse. Programmers may decide to create internal abstractions so that certain parts of their program can be reused, or may create custom libraries for their own use. Some characteristics that make software more easily reusable are [[Modularity (programming)|modularity]], [[loose coupling]], high [[Cohesion (computer science)|cohesion]], [[information hiding]] and [[separation of concerns]].
Line 33 ⟶ 36:
* Internal reuse – A team reuses its own components. This may be a business decision, since the team may want to control a component critical to the project.
* External reuse – A team may choose to license a third-party component. Licensing a third-party component typically costs the team 1 to 20 percent of what it would cost to develop internally.<ref>{{cite book |last=McConnell |first=Steve |title=Rapid Development: Taming Wild Software Schedules |year=1996 |publisher=Pearson Education |isbn=978-1-55615-900-8 |url-access=registration |url=https://archive.org/details/rapiddevelopment00mcco }}</ref> The team must also consider the time it takes to find, learn and integrate the component.
Concerning form or structure of reuse, code can be:<ref name="sharednow.blogspot.com">{{cite web |last=Colombo |first=F. |year=2011 |title=It's not just reuse |work=SharedNow.blogspot |url=
* Referenced – The client code contains a reference to reused code, and thus they have distinct life cycles and can have distinct versions.
* 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.
Line 43 ⟶ 46:
==Systematic==
{{expand section|date=April 2015}}
Systematic software reuse is a strategy for increasing productivity and improving the quality of the software industry. Although it is simple in concept, successful software reuse implementation is difficult in practice. A reason put forward for this is the dependence of software reuse on the context in which it is implemented. Some problematic issues that need to be addressed related to systematic software reuse are:<ref>{{cite conference |last1=Champman |first1=M. |last2=Van der Merwe |first2=Alta |year=2008 |url=http://portal.acm.org/citation.cfm?id=1456662 |title=Contemplating Systematic Software Reuse in a Small Project-centric Company |book-title=Proceeding SAICSIT '08 Proceedings of the 2008 annual research conference of the South African Institute of Computer Scientists and Information Technologists on IT research in developing countries: riding the wave of technology |doi=10.1145/1456659.1456662 |isbn=978-1-60558-286-3 |url-access=subscription }}</ref>
*a clear and well-defined product vision is an essential foundation to
*an evolutionary implementation strategy would be a more pragmatic strategy for the company.
*there exist a need for continuous management support and leadership to ensure success.
Line 66 ⟶ 69:
{{main article|Software framework}}
Developers generally reuse large pieces of software via third-party applications and frameworks
===Higher-order function===
Line 86 ⟶ 89:
{{main article|Software component}}
A component, in an object-oriented extent, represents a set of collaborative classes (or only one class) and its interfaces. The interfaces are responsible for enabling the replacement of components. Reusable components can also be isolated and synchronized between SCM repositories using component source code management technologies ([https://github.com/teambit/bit CSCM]).{{citation needed|date=April 2015}}
===Outside computers===
Line 93 ⟶ 96:
== Criticism ==
Code reuse results in [[Coupling (computer programming)|dependency]] on the component being reused. [[Rob Pike]] opined that "A little copying is better than a little dependency". When he joined [[Google]], the company was putting heavy emphasis on code reuse. He believes that Google's [[codebase]] still suffers from results of that former policy in terms of compilation speed and maintainability.<ref>{{Citation|last=The Go Programming Language|title=Go Proverbs – Rob Pike – Gopherfest – November 18, 2015|date=2015-12-01|url=https://www.youtube.com/watch?v=PAAkCSZUG1c |archive-url=https://ghostarchive.org/varchive/youtube/20211222/PAAkCSZUG1c |archive-date=2021-12-22 |url-status=live|accessdate=26 February 2016}}{{cbignore}}</ref>
Reusable code requires usually more effort to write and design. [[Fred Brooks]] discusses the significantly higher cost associated with that effort in his essays "The Tar Pit" and "[[No Silver Bullet]]" The fallacy is that effort is often spent without careful understanding of the mechanisms through which that cost will be redeemed. The justification often comes from incorrectly drawing parallels to reusable parts in a physical manufacturing process. Incorrect because writing code is analogous to design of a single product rather than production of multiple units.
==See also==
*[[Don't repeat yourself]]
*[[International Conference on Software Reuse
*[[Inheritance (
*[[Language binding]]
*[[Not invented here]] ([[antonym]])
*[[Type polymorphism
*[[Procedural programming]]
*[[Reinventing the wheel]] ([[antonym]])
*[[Reuse metrics]]
*[[Single source of truth]]
|