论文标题
替换和替换:为代码变体提供理由
Replacements and Replaceables: Making the Case for Code Variants
论文作者
论文摘要
通常有多种方法可以在源代码中实现相同的要求。不同的实现选择可能会导致相似的代码段,并以多种方式定义:代码克隆,示例,模拟和变体。当前,缺乏对此类代码段的一致和明确的定义。在这里,我们提出了代码变体的特征研究 - 在给定代码上下文中,彼此之间至少有一个所需的属性相互不同的特定类型的代码片段。我们将代码变体与源代码中的其他类型的裁员区分开来,并演示它们扮演的重要角色:大约25%至43%的开发人员讨论(在九个开源项目中)是关于变体的。我们根据其代码上下文和所需属性来表征不同类型的变体。为了证明我们可能使用代码变体的表征,我们展示了如何根据所需属性(例如执行速度)对搜索结果进行排名。
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).