Software Code Fragment
A Software Code Fragment is a source code item that is an item fragment.
- AKA: Code Snippet, Code Segment, Source Code Snippet, Source Code Segment.
- Context:
- ...
- It can range from being a Source Code Line Fragment to being a Source Code Block Fragment, depending on its code scope.
- It can range from being a Source Code Expression Fragment to being a Source Code Algorithm Fragment, depending on its logical complexity.
- It can range from being a Source Code Partial Fragment to being a Source Code Module Fragment, depending on its implementation completeness.
- ...
- It can often express Source Code Logic through source code statements.
- It can demonstrate Source Code Patterns through source code structures.
- It can show Source Code Algorithm through source code instructions.
- It can illustrate Source Code Practices through source code implementations.
- It can support Documentation Purposes through source code examples.
- It can enable Knowledge Transfer through source code sharing.
- It can facilitate Learning Processs through source code samples.
- ...
- Example(s):
- Programming Language-Specific Fragments (for some specific programming language), such as:
- Source Code Structure Fragments, such as:
- ...
- Counter-Example(s):
- a Source Code File, which contains a complete implementation.
- a Compilable Code Item, which forms a complete unit.
- a Text Fragment, which contains natural language rather than source code syntax.
- See: DNA Fragment, Software Code Implementation, Programming Language, Code Structure, Code Pattern, DNA Fragment, Source Code Item, Source-Code Summarization Task, Software Code Auto-Completion Task, GitHub Gist Service.
References
2018
- (Horton & Parnin, 2018) ⇒ Eric Horton, and Chris Parnin. (2018). "Gistable: Evaluating the Executability of Python Code Snippets on GitHub." arXiv preprint arXiv:1808.04919
- ABSTRACT: Software developers create and share code online to demonstrate programming language concepts and programming tasks. Code snippets can be a useful way to explain and demonstrate a programming concept, but may not always be directly executable. A code snippet can contain parse errors, or fail to execute if the environment contains unmet dependencies.
This paper presents an empirical analysis of the executable status of Python code snippets shared through the GitHub gist system, and the ability of developers familiar with software configuration to correctly configure and run them. We find that 75.6% of gists require non-trivial configuration to overcome missing dependencies, configuration files, reliance on a specific operating system, or some other environment configuration. Our study also suggests the natural assumption developers make about resource names when resolving configuration errors is correct less than half the time.
We also present Gistable, a database and extensible framework built on GitHub's gist system, which provides executable code snippets to enable reproducible studies in software engineering. Gistable contains 10,259 code snippets, approximately 5,000 with a Dockerfile to configure and execute them without import error. Gistable is publicly available at this https URL
- ABSTRACT: Software developers create and share code online to demonstrate programming language concepts and programming tasks. Code snippets can be a useful way to explain and demonstrate a programming concept, but may not always be directly executable. A code snippet can contain parse errors, or fail to execute if the environment contains unmet dependencies.