Code reuse
Encyclopedia
Code reuse, also called software reuse, is the use of existing software, or software knowledge, to build new software.

Overview

Ad hoc
Ad hoc
Ad hoc is a Latin phrase meaning "for this". It generally signifies a solution designed for a specific problem or task, non-generalizable, and not intended to be able to be adapted to other purposes. Compare A priori....

 code reuse has been practiced from the earliest days of programming
Computer programming
Computer programming is the process of designing, writing, testing, debugging, and maintaining the source code of computer programs. This source code is written in one or more programming languages. The purpose of programming is to create a program that performs specific operations or exhibits a...

. 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
Douglas McIlroy
Malcolm Douglas McIlroy is a mathematician, engineer, and programmer. As of 2007 he is an Adjunct Professor of Computer Science at Dartmouth College. Dr...

 of Bell Laboratories
Bell Labs
Bell Laboratories is the research and development subsidiary of the French-owned Alcatel-Lucent and previously of the American Telephone & Telegraph Company , half-owned through its Western Electric manufacturing subsidiary.Bell Laboratories operates its...

 proposed basing the software industry on reusable components.

Code reuse is the idea that a partial computer program
Computer program
A computer program is a sequence of instructions written to perform a specified task with a computer. A computer requires programs to function, typically executing the program's instructions in a central processor. The program has an executable form that the computer can use directly to execute...

 written at one time can be, should be, or is being used in another program written at a later time. The reuse of programming code is a common technique which attempts to save time and energy by reducing redundant work.

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
Modularity (programming)
Modular programming is a software design technique that increases the extent to which software is composed of separate, interchangeable components called modules by breaking down program functions into modules, each of which accomplishes one function and contains everything necessary to accomplish...

, loose coupling
Loose coupling
In computing and systems design a loosely coupled system is one where each of its components has, or makes use of, little or no knowledge of the definitions of other separate components. The notion was introduced into organizational studies by Karl Weick...

, high cohesion
Cohesion (computer science)
In computer programming, cohesion is a measure of how strongly-related each piece of functionality expressed by the source code of a software module is...

, information hiding
Information hiding
In computer science, information hiding is the principle of segregation of the design decisions in a computer program that are most likely to change, thus protecting other parts of the program from extensive modification if the design decision is changed...

 and separation of concerns
Separation of concerns
In computer science, separation of concerns is the process of separating a computer program into distinct features that overlap in functionality as little as possible. A concern is any piece of interest or focus in a program. Typically, concerns are synonymous with features or behaviors...

.

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
Subroutine
In computer science, a subroutine is a portion of code within a larger program that performs a specific task and is relatively independent of the remaining code....

, object
Object (computer science)
In computer science, an object is any entity that can be manipulated by the commands of a programming language, such as a value, variable, function, or data structure...

, class
Class (computer science)
In object-oriented programming, a class is a construct that is used as a blueprint to create instances of itself – referred to as class instances, class objects, instance objects or simply objects. A class defines constituent members which enable these class instances to have state and behavior...

, or prototype
Prototype-based programming
Prototype-based programming is a style of object-oriented programming in which classes are not present, and behavior reuse is performed via a process of cloning existing objects that serve as prototypes. This model can also be known as classless, prototype-oriented or instance-based programming...

. In organizations, such practices are formalized and standardized by Domain engineering
Domain engineering
Domain engineering, also called product line engineering, is the entire process of reusing domain knowledge in the production of new software systems. It is a key concept in systematic software reuse. A key idea in systematic software reuse is the application domain, a software area that contains...

 aka software product line
Product Family Engineering
Product family engineering , also known as product line engineering, is a synonym for "domain engineering" created by the Software Engineering Institute, a term coined by James Neighbors in his 1980 dissertation at University of California, Irvine...

 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
Time to market
In commerce, time to market is the length of time it takes from a product being conceived until its being available for sale. TTM is important in industries where products are outmoded quickly...

 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
Object-oriented programming
Object-oriented programming is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction,...

, which became one of the most common forms of formalized reuse. A somewhat later invention is generic programming
Generic programming
In a broad definition, generic programming is a style of computer programming in which algorithms are written in terms of to-be-specified-later types that are then instantiated when needed for specific types provided as parameters...

.

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
Metaprogramming
Metaprogramming is the writing of computer programs that write or manipulate other programs as their data, or that do part of the work at compile time that would otherwise be done at runtime...

.

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.


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

Software libraries

A very common example of code reuse is the technique of using a software library
Library (computer science)
In computer science, a library is a collection of resources used to develop software. These may include pre-written code and subroutines, classes, values or type specifications....

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

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.

Systematic software reuse

Systematic software reuse is still the most promising strategy for increasing productivity and improving quality in 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 needs to be addressed related to systematic software reuse are :
  • a clear and well-defined product vision is an essential foundation to an 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.

See also

  • Don't repeat yourself
    Don't repeat yourself
    In software engineering, Don't Repeat Yourself is a principle of software development aimed at reducing repetition of information of all kinds, especially useful in multi-tier architectures...

  • Single Source of Truth
    Single Source of Truth
    In Information Systems design and theory, as instantiated at the Enterprise Level, Single Source Of Truth refers to the practice of structuring information models and associated schemata such that every data element is stored exactly once...

  • ICSR
    International Conference on Software Reuse
    The International Conference on Software Reuse , is the primary scientific conference on software reuse, domain analysis, and domain engineering....

  • Inheritance
    Inheritance (computer science)
    In object-oriented programming , inheritance is a way to reuse code of existing objects, establish a subtype from an existing object, or both, depending upon programming language support...

  • Not Invented Here
    Not Invented Here
    Not invented here is a term used to describe persistent social, corporate, or institutional culture that avoids using or buying already existing products, research, standards, or knowledge because of their external origins. It is normally used in a pejorative sense, and may be considered an...

     (antonym
    Antonym
    In lexical semantics, opposites are words that lie in an inherently incompatible binary relationship as in the opposite pairs male : female, long : short, up : down, and precede : follow. The notion of incompatibility here refers to the fact that one word in an opposite pair entails that it is not...

    )
  • Procedural programming
    Procedural programming
    Procedural programming can sometimes be used as a synonym for imperative programming , but can also refer to a programming paradigm, derived from structured programming, based upon the concept of the procedure call...

  • Reinventing the wheel
    Reinventing the wheel
    To reinvent the wheel is to duplicate a basic method that has already previously been created or optimized by others.The inspiration for this idiomatic metaphor lies in the fact that the wheel is the archetype of human ingenuity, both by virtue of the added power and flexibility it affords its...

     (antonym
    Antonym
    In lexical semantics, opposites are words that lie in an inherently incompatible binary relationship as in the opposite pairs male : female, long : short, up : down, and precede : follow. The notion of incompatibility here refers to the fact that one word in an opposite pair entails that it is not...

    )
  • Reuse metrics
    Reuse metrics
    Many metrics and models have been developed for software reuse and reusability. A metric is a quantitative indicator of an attribute of a thing. A model specifies relationships among metrics...

  • Software framework
    Software framework
    In computer programming, a software framework is an abstraction in which software providing generic functionality can be selectively changed by user code, thus providing application specific software...

  • Polymorphism
    Type polymorphism
    In computer science, polymorphism is a programming language feature that allows values of different data types to be handled using a uniform interface. The concept of parametric polymorphism applies to both data types and functions...

  • Virtual inheritance
    Virtual inheritance
    Virtual inheritance is a topic of object-oriented programming. It is a kind of inheritance in which the part of the object that belongs to the virtual base class becomes common direct base for the derived class and any next class that derives from it...


External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK