Code reuse: Difference between revisions

Content deleted Content added
code reuse is not the same as software reuse; what's a reusability principal?
Bender the Bot (talk | contribs)
m Types of reuse: HTTP to HTTPS for Blogspot
 
(10 intermediate revisions by 5 users not shown)
Line 1:
{{shortShort description||Practice of usingUsing existing code/software insteadin ofnew developing itsoftware}}
 
'''Code reuse''' is the practice of using existing [[source code]] to develop [[software]] instead of writing new code. '''Software reuse''' is a broader term that implies using any existing software asset to develop software instead of developing it again.<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}} An asset that is relatively easy to reuse and offers significant value is considered to have high [[reusability]].
 
Code reuse may be achieved by different ways depending on a complexity of a [[programming language]] chosen and range from a lower-level approaches like code [[Cut, copy, and paste|copy-pasting]] (e.g. via [[Snippet (programming)|snippets]]),<ref>{{Cite journal|last1=Selaolo|first1=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|journal=Advances in Computer Science|volume=5|pages=63|via=ResearchgateResearchGate}}</ref> simple functions ([[Procedure (computer science)|procedure]]s or [[subroutine]]s) or a bunch of [[Object (computer science)|objects]] or [[Subroutine|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 [[namespace]]s, and [[Package manager|package]]s, [[Framework (computer science)|framework]]s or [[software suite]]s in higher-levels.
 
Code reuse implies dependencies which can make [[Software maintenance|code maintainability]] harder.{{Citation needed|date=February 2023}}
At least one study found that code reuse at the class level reduces [[technical debt]].<ref>{{Cite journal|last1=Feitosa|first1=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://pure.rug.nl/ws/files/128142562/1_s2.0_S0164121220300960_main.pdf|journal=Journal of Systems and Software|language=en|volume=167|pagesarticle-number=110618|doi=10.1016/j.jss.2020.110618|s2cid=219502749|url-access=|url-status=|archive-url=|archive-date=}}</ref>
 
==Overview==
Line 14:
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>
 
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 38:
* 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=httphttps://sharednow.blogspot.com/2011/05/its-not-just-reuse.html}}</ref>
* 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 108:
*[[Procedural programming]]
*[[Reinventing the wheel]] ([[antonym]])
*[[Reusability]]
*[[Reuse metrics]]
*[[Single source of truth]]