Snippet (programming) in the context of "Software reuse"

Play Trivia Questions online!

or

Skip to study material about Snippet (programming) in the context of "Software reuse"




⭐ Core Definition: Snippet (programming)

In computer programming, a snippet is a relatively small amount of source code that is stored and later inserted into a larger codebase as part of the process of writing the code. Some development tools such as a code editor or an integrated development environment (IDE) provide snippet management features to enhance productivity by allowing a developer to insert a fragment of code instead of typing it.

In contrast to an abstraction construct, such as a function, a snippet is a form of copy and paste programming – a macro operation that expands the stored template text and inserts the result into the source code. Snippet insertion is similar to a preprocessor macro except that it's like inserting the expansion of the macro definition rather than referencing it. Changing the snippet after insertion does not affect the code as does changing the definition of a preprocessor macro. For this reason, best practice is to use a snippet only for relatively simple code such as a function prototype, control structure, or library import. A snippet is typically used when an abstraction is not available (i.e. not supported by the programming language) or not desirable (i.e. due to runtime overhead).

↓ Menu

👉 Snippet (programming) in the context of Software reuse

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. An asset that is relatively easy to reuse and offers significant value is considered to have high reusability.

Code reuse may be achieved 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), simple functions (procedures or subroutines) or a bunch of objects or functions organized into modules (e.g. libraries) or custom namespaces, and packages, frameworks or software suites in higher-levels.

↓ Explore More Topics
In this Dossier

Snippet (programming) in the context of Source code

In computing, source code, or simply code or source, is human readable plain text that can eventually result in controlling the behavior of a computer. In order to control a computer, it must be processed by a computer program – either executed directly via an interpreter or translated into a more computer-consumable form such as via a compiler. Sometimes, code is compiled directly to machine code so that it can be run in the native language of the computer without further processing. But, many modern environments involve compiling to an intermediate representation such as bytecode that can either run via an interpreter or be compiled on-demand to machine code via just-in-time compilation.

↑ Return to Menu