替代品和可替代品:为代码变体提供理由
Replacements and Replaceables: Making the Case for Code Variants
摘要:
在源代码中实现相同的需求通常有多种方法。不同的实现选择可能会导致类似的代码片段,并以多种方式定义:代码克隆,示例,simions和变体。目前,对于这种类型的代码片段缺乏一致和明确的定义。在这里,我们提出了一个表征研究的代码变体-一种特定类型的代码片段,彼此不同的至少一个所需的属性,在一个给定的代码上下文。我们将代码变体与源代码中其他类型的冗余区分开来,并展示了它们所扮演的重要角色:大约25%到43%的开发人员讨论(在一组9个开源项目中)是关于变体的。我们根据它们的代码上下文和所需的属性来描述不同类型的变体。作为对我们的代码变体的表征的可能使用的演示,我们展示了如何基于期望的属性(例如,执行速度)。
英文摘要:
There are often multiple ways to implement the same requirement in source code. Different implementation choices can result in code snippets that are similar, and have been defined in multiple ways: code clones, examples, simions and variants. Currently, there is a lack of a consistent and unambiguous definition of such types of code snippets. Here we present a characterization study of code variants - a specific type of code snippets that differ from each other by at least one desired property, within a given code context. We distinguish code variants from other types of redundancies in source code, and demonstrate the significant role that they play: about 25% to 43% of developer discussions (in a set of nine open source projects) were about variants. We characterize different types of variants based on their code context and desired properties. As a demonstration of the possible use of our characterization of code variants, we show how search results can be ranked based on a desired property (e.g., speed of execution).
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。