Code reuse

In software development (and computer programming in general), code reuse, also called software reuse, is the use of existing software, or software knowledge, to build new software,[1][2]: 7  following the reusability principles.

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 copy-pasting (e.g. via snippets),[3] simple functions (procedures or subroutines) or a bunch of objects or functions organized into modules (e.g. libraries)[4][2]: 7  or custom namespaces, and packages, frameworks or software suites in higher-levels.

Code reuse implies dependencies which can make code maintainability harder.[citation needed] At least one study found that code reuse at the class level reduces technical debt.[5]

Overview

Ad hoc code reuse has been practiced from the earliest days of 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 Laboratories proposed basing the software industry on reusable components.

Code reuse aims to save time and resources and reduce redundancy by taking advantage of assets that have already been created in some form within the software product development process.[6] 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.[7]

The 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, loose coupling, high cohesion, information hiding and separation of concerns.

For newly written code to use a piece of existing code, some kind of interface, or means of communication, must be defined. These commonly include a "call" or use of a subroutine, object, class, or prototype. In organizations, such practices are formalized and standardized by domain engineering, also known as software product line engineering.

The general practice of using a prior version of an extant program as a starting point for the next version, is also a form of code reuse.

Some so-called code "reuse" involves simply copying some or all of the code from an existing program into a new one. While organizations can realize time to market benefits for a new product with this approach, they can subsequently be saddled with many of the same code duplication problems caused by cut and paste programming.

Many researchers have worked to make reuse faster, easier, more systematic, and an integral part of the normal process of programming. These are some of the main goals behind the invention of object-oriented programming, which became one of the most common forms of formalized reuse. A somewhat later invention is generic programming.

Another, newer means is to use software "generators", programs which can create new programs of a certain type, based on a set of parameters that users choose. Fields of study about such systems are generative programming and metaprogramming.

Types of reuse

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'll be reusable in future projects.

Reuse can be categorized further:

  • 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.[8] 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:[9]

  • 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.

Fork-reuse is often discouraged because it'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.[9]

Systematic

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:[10]

  • a clear and well-defined product vision is an essential foundation to a software product line (SPL).
  • 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.
  • an appropriate organisational structure is needed to support SPL engineering.
  • the change of mindset from a project-centric company to a product-oriented company is essential.

Examples

Software libraries

A very common example of code reuse is the technique of using a software library. Many common operations, such as converting information among different well-known formats, accessing external storage, interfacing with external programs, or manipulating information (numbers, words, names, locations, dates, etc.) in common ways, are needed by many different programs. Authors of new programs can use the code in a software library to perform these tasks, instead of "re-inventing the wheel", by writing fully new code directly in a program to perform an operation. Library implementations often have the benefit of being well-tested and covering unusual or arcane cases. Disadvantages include the inability to tweak details which may affect performance or the desired output, and the time and cost of acquiring, learning, and configuring the library.[11]

Design patterns

A design pattern is a general solution to a recurring problem. Design patterns are more conceptual than tangible and can be modified to fit the exact need. However, abstract classes and interfaces can be reused to implement certain patterns.

Frameworks

Developers generally reuse large pieces of software via third-party applications and frameworks, though frameworks are usually domain-specific and applicable only to families of applications[citation needed].

Higher-order function

In functional programming higher-order functions can be used in many cases where design patterns or frameworks were formerly used.

Retrocomputing

Retrocomputing encompasses reuse of code, simply because retro programs are being run on older computers, or emulators for them.

Computer security

In computer security code-reuse is employed as a software exploit method.[12] When an attacker is not able to directly input code to modify the control flow of a program, for example in presence of code injection defenses such as W^X, he or she can redirect the control flow to code sequences existing in memory.

Examples of code-reuse attacks are return-to-libc attack, return-oriented programming, and jump-oriented programming.[12][13]

Components

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 (CSCM).[citation needed]

Outside computers

The whole concept of "code reuse" can also encompass engineering applications outside software. For instance, parametric modeling in computer-aided design allows for creating reusable designs. Standardization results in creation of interoperable parts that can be then reused in many contexts.[citation needed]

Criticism

Code reuse results in 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.[14]

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

References

  1. ^ Frakes, W.B.; Kyo Kang (July 2005). "Software Reuse Research: Status and Future". IEEE Transactions on Software Engineering. 31 (7): 529–536. CiteSeerX 10.1.1.75.635. doi:10.1109/TSE.2005.85. S2CID 14561810.
  2. ^ a b Reddy, Martin (2011). API design for C++. Boston: Morgan Kaufmann. ISBN 978-0-12-385004-1. OCLC 704559821.
  3. ^ Selaolo, Karabo; Hlomani, Hlomani (2016). "Towards An Algorithms Ontology Cluster: for Modular Code Reuse and Polyglot Programming". Advances in Computer Science. 5: 63 – via Researchgate.
  4. ^ "4. Code Reuse: Functions and Modules - Head First Python, 2nd Edition [Book]". www.oreilly.com. Retrieved 2022-01-26.
  5. ^ Feitosa, Daniel; Ampatzoglou, Apostolos; Gkortzis, Antonios; Bibi, Stamatia; Chatzigeorgiou, Alexander (September 2020). "CODE reuse in practice: Benefiting or harming technical debt" (PDF). Journal of Systems and Software. 167: 110618. doi:10.1016/j.jss.2020.110618. S2CID 219502749.
  6. ^ Lombard Hill Group. "What Is Software Reuse?". lombardhill.com. Lombard Hill Group. Archived from the original on 23 January 2019. Retrieved 22 October 2014.
  7. ^ Lombard Hill Group. "What Is Software Reuse?". Archived from the original on 23 January 2019. Retrieved 22 October 2014.
  8. ^ McConnell, Steve (1996). Rapid Development: Taming Wild Software Schedules. Pearson Education. ISBN 978-1-55615-900-8.
  9. ^ a b Colombo, F. (2011). "It's not just reuse". SharedNow.blogspot.
  10. ^ Champman, M.; Van der Merwe, Alta (2008). "Contemplating Systematic Software Reuse in a Small Project-centric Company". 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.
  11. ^ "Code reuse". DocForge. Archived from the original on 2011-07-10. Retrieved 29 October 2024.
  12. ^ a b Bletsch, Tyler (2011). Code-reuse Attacks: New Frontiers and Defenses. North Carolina State University. ISBN 978-1-124-75297-6.
  13. ^ Bletsch, Tyler; Jiang, Xuxian; Freeh, Vince W; Liang, Zhenkai (2011). "Jump-oriented programming: a new class of code-reuse attack" (PDF). Proceedings of the 6th ACM Symposium on Information, Computer and Communications Security. ACM. pp. 30–40. doi:10.1145/1966913.1966919. ISBN 978-1-4503-0564-8. Archived from the original (PDF) on 2017-08-07. Retrieved 2017-08-07.
  14. ^ The Go Programming Language (2015-12-01), Go Proverbs – Rob Pike – Gopherfest – November 18, 2015, archived from the original on 2021-12-22, retrieved 26 February 2016

Read other articles:

This article relies excessively on references to primary sources. Please improve this article by adding secondary or tertiary sources. Find sources: Frontier Medical College – news · newspapers · books · scholar · JSTOR (November 2010) (Learn how and when to remove this template message) Frontier Medical & Dental College, AbbottabadMottoExcellence and InnovationTypePrivate / Private-sectorEstablished10 April 1995ChairmanAbdul Jamil KhanDeanProf Dr ...

 

 

1959 compilation album by John Fahey Blind Joe DeathStudio album by John FaheyReleased1959Recorded1959, St. Michael's and All Angels Church, Adelphi, MarylandGenreAmerican PrimitivismLength43:21 (1959 version)LabelTakomaProducerJohn FaheyJohn Fahey chronology Blind Joe Death(1959) Death Chants, Breakdowns & Military Waltzes(1963) Alternative coverCover of the 1967 stereo release of the LP(design by Tom Weller) Blind Joe Death is the first album by American fingerstyle guitarist and co...

 

 

Congratulations: 50 Tahun Kontes Lagu Eurovision Final 22 Oktober 2005 Pembawa Acara Katrina LeskanichRenārs Kaupers Penyiar Tuan Rumah EBU, DR Tempat Forum Arena, Kopenhagen, Denmark Lagu pemenang Waterloo by ABBA Sistem pemberian suara PSE dan juri; setiap negara memberikan 1-8, 10, dna12 poin kepada 10 lagu favorit mereka Jumlah kontestan 14 lagu dari 1958 sampai 2005 Interval Riverdance,Ronan Keating,Bermacam-macam medley Congratuations: 50 Tahun Kontes Lagu Eurovision adalah acara telev...

Sporting event delegationAndorra at the1992 Summer OlympicsIOC codeANDNOCAndorran Olympic CommitteeWebsite (in Catalan)in BarcelonaCompetitors8 (7 men and 1 woman) in 5 sportsFlag bearer Margarida MorenoMedals Gold 0 Silver 0 Bronze 0 Total 0 Summer Olympics appearances (overview)1976198019841988199219962000200420082012201620202024 Andorra competed at the 1992 Summer Olympics in Barcelona, Spain. Eight competitors, seven men and one woman, took part in five events in five sports. ...

 

 

  لمعانٍ أخرى، طالع فرد تايلور (توضيح). فرد تايلور   معلومات شخصية الميلاد سنة 1884  روثرهام  [لغات أخرى]‏  الوفاة القرن 20  بيتربرة  الطول 5 قدم 8 بوصة (1.73 م) مركز اللعب وسط الجنسية المملكة المتحدة المملكة المتحدة لبريطانيا العظمى وأيرلندا  المس

 

 

Este artículo o sección necesita referencias que aparezcan en una publicación acreditada.Este aviso fue puesto el 26 de septiembre de 2013. Skank Samuel Rosa cantante y guitarrista en conciertoDatos generalesOrigen Belo Horizonte, Brasil Brasil BrasilInformación artísticaGénero(s) Rock AlternativoPop RockReggae rockskaPeríodo de actividad 1991 – presenteDiscográfica(s) Epic Sony BMGArtistas relacionados TitãsThe PoliceChico BuarqueLed ZeppelinOs Paralamas do SucessoG...

1264 settlement between King Henry III of England and Simon de Montfort Mise of AmiensSettlement between King Henry III of England and oppositional magnatesSaint Louis's settlement between King Henry III of England and his barons, history painting by Georges Rouget, 1820TypeSettlementSigned23 January 1264LocationAmiens, Picardy, FranceEffectiveImmediatelyLanguageLatin The Mise[a] of Amiens ([miz ɒv a.mjɛ̃]) was a settlement given by King Louis IX of France on 23 January 126...

 

 

American college football season 1919 Oregon Webfoots footballPCC co-championRose Bowl, L 6–7 vs. HarvardConferencePacific Coast ConferenceRecord5–2 (2–1 PCC)Head coachCharles A. Huntington (2nd season)CaptainEverett BrandenbergHome stadiumKincaid Field, Hayward Field, Multnomah FieldSeasons← 19181920 → 1919 Pacific Coast Conference football standings vte Conf Overall Team W   L   T W   L   T Oregon ^ + 2 – 1 – 0 5 – ...

 

 

American professional wrestler (born 1990) This biography of a living person needs additional citations for verification. Please help by adding reliable sources. Contentious material about living persons that is unsourced or poorly sourced must be removed immediately from the article and its talk page, especially if potentially libelous.Find sources: John Silver wrestler – news · newspapers · books · scholar · JSTOR (October 2020) (Learn how and w...

Deutsch-Polnische Gesellschaft Bundesverband e. V. (dpgb) Rechtsform eingetragener Verein Gründung 18. Januar 1986 in Hannover Sitz Berlin Geschäftsstelle Schillerstraße 59, 10627 Berlin Vorläufer Arbeitsgemeinschaft Deutsch-Polnische Verständigung e. V. Zweck deutsch-polnische Zusammenarbeit Vorsitz Simona Koß (Vorstandsvorsitzende) Personen Irene Hahn-Fuhr, Peter A. Kokocinski, Johannes von Thadden (Stellvertretende Vorstandsvorsitzende) Mitglieder 3000 (2021) Website www.dp...

 

 

Cet article est une ébauche concernant le monde insulaire, l’océan Indien et le Kenya. Vous pouvez partager vos connaissances en l’améliorant (comment ?) selon les recommandations des projets correspondants. Consultez la liste des tâches à accomplir en page de discussion. Pour les articles homonymes, voir Lamu. Archipel de LamuVisiwa cha Lamu (sw) Vue aérienne de Shela sur l'île de Lamu. Géographie Pays Kenya Localisation Océan Indien Coordonnées 2° 12′ 39...

 

 

Lukisan Raft of the MedusaThe Raft of the Medusa (Le Radeau de la Méduse) adalah karya lukisan cat minyak yang dibuat oleh pelukis dan penulis litografi asal Prancis yang bernama Jean-Louis André Théodore Géricault.[1] Lukisan yang dibuat pada abad ke-19 tersebut dianggap sebagai ikon romantisisme yang menggambarkan aspek kemanusiaan dan politik.[2][3] Lukisan kontroverisal yang dilukis oleh Jean-Louis André Théodore Géricault tersebut menggambarkan kisah yang m...

Mansion in Aldbury, Hertfordshire, England This article is about the building in Hertfordshire, England, UK. For a facility housing a shares trading venture, see stock exchange and stock market. Stocks HouseStocks House, pictured in around 1995Location of Stocks House in HertfordshireFormer namesLa StokGeneral informationTypeEnglish country houseArchitectural styleNeoclassicalTown or cityAldbury, HertfordshireCountryUnited KingdomCoordinates51°48′38″N 0°36′20″W / 51....

 

 

Earthquakes in 1951class=notpageimage| Approximate epicenters of the earthquakes in 1951 4.0–5.9 magnitude 6.0–6.9 magnitude 7.0–7.9 magnitude 8.0+ magnitude Strongest magnitude Taiwan, Hualien County (Magnitude 7.8) November 24Deadliest El Salvador, off the coast of (Magnitude 6.5) May 6, 1,100 deathsTotal fatalities2,236Number by magnitude9.0+0← 19501952 → This is a list of earthquakes in 1951. Only magnitude 6.0 or greater earthquakes appear on t...

 

 

臺灣歷史 | 台灣歷史年表 世纪: 19世纪臺灣 | 20世纪臺灣 | 21世纪臺灣 年代: 1930年代臺灣 | 1940年代臺灣 | 1950年代臺灣 | 1960年代臺灣 | 1970年代臺灣 | 1980年代臺灣 | 1990年代臺灣 年份: 1956年臺灣 | 1957年臺灣 | 1958年臺灣 | 1959年臺灣 | 1960年臺灣 | 1961年臺灣 | 1962年臺灣 | 1963年臺灣 | 1964年臺灣 | 1965年臺灣 | 1966年臺灣 纪年: 辛丑年(牛年)、中華民國50年 1961年 政治 国家领导...

Penyebaran kamp konsentrasi Jepang di seluruh negeri jajahannya. Kamp konsentrasi Jepang adalah nama yang digunakan Belanda untuk menyebut kamp interniran yang didirikan untuk menahan penduduk sipil atau tawanan militer selama pendudukan Jepang di Indonesia (1942-1945) yang berada di bawah pengawasan Jepang. Oleh pemerintah kolonial Jepang, sebagai warga dari tempat yang diperintah Jepang selama Perang Pasifik, orang Belanda disebut sebagai warga asing yang merupakan musuh. Kamp interniran Je...

 

 

Bay in Worcester County, MarylandSinepuxent BayThe Sinepuxent Bay crossed by the Harry W. Kelley Memorial Bridge, looking south. The southern end of Ocean City, the Ocean City Inlet, the northern tip of Assateague Island, the south inlet jetty, and the Atlantic Ocean are at the top of the image. Skimmer Island is in the left-center and Horn Island is in the right center of the picture, in front of the bridge.Sinepuxent BayLocationWorcester County, Maryland[1]Coordinates38°15′00″N...

 

 

For the London Underground station, see Clapham Common tube station. Clapham CommonClapham Common station, 1863LocationClaphamOwnerLondon and South Western RailwayKey dates1838 (1838)Opened as Wandsworth1846renamed Clapham Common1863 (1863)ClosedReplaced byClapham JunctionOther information London transport portal Clapham Common was a railway station in Clapham formerly located between Vauxhall and Wimbledon stations.[1] The station was opened by the London and South...

NFL team season 2018 New Orleans Saints seasonOwnerGayle Benson[1]General managerMickey LoomisHead coachSean PaytonOffensive coordinatorPete Carmichael Jr.Defensive coordinatorDennis AllenHome fieldMercedes-Benz SuperdomeResultsRecord13–3Division place1st NFC SouthPlayoff finishWon Divisional Playoffs(vs. Eagles) 20–14Lost NFC Championship(vs. Rams) 23–26 (OT)Pro Bowlers 8 QB Drew Brees RB Alvin Kamara WR Michael Thomas T Terron Armstead G Andrus Peat G Larry Warford C Max ...

 

 

American javelin thrower (b. 1986) Kara WingerKara Winger in 2010Personal informationBirth nameKara Estelle PattersonNationalityAmericanBorn (1986-04-10) April 10, 1986 (age 37)Seattle, Washington, U.S.Height6 ft 1.75 in (187 cm)Weight185 lb (84 kg)Websitekarathrowsjavelin.blogspot.comSportSportAthleticsEventJavelin throwAchievements and titlesHighest world ranking1st (2023)Personal bestNR 68.11 m (2022) Medal record Women's athletics Representing the &...

 

 

Strategi Solo vs Squad di Free Fire: Cara Menang Mudah!