Mason: 基于类型和名称的程序合成
Mason: Type- and Name-Guided Program Synthesis
AI总结:
Mason通过类型和名称引导合成技术,自动将设计模式插入到面向对象程序中,提升了多类程序合成的效率和准确性。
摘要:
面向对象程序往往使用许多常见的编码惯用法,如那些被设计模式所捕捉的。尽管设计模式很有用,但实现它们通常很繁琐且重复,需要大量样板代码,这会分散程序员的注意力,使其无法关注更关键的细节。在本文中,我们介绍了一个名为Mason的工具,它能够从部分程序片段中合成面向对象程序,并将其应用于自动将设计模式插入到程序中。Mason的核心是一种称为类型和名称引导合成的新技术,其中枚举求解器遍历部分程序以生成类型约束;通过由受约束类型和成员名称引导的程序转换来消除约束;并在约束被违反或候选程序失败单元测试时回溯。我们还介绍了两个Mason的扩展:一个非局部回溯启发式方法,它使用执行轨迹,以及一个强制执行模式的语言,它对缺失的名称施加语法限制。我们对一系列基准测试进行了评估,这些基准测试要求Mason必须添加各种著名的设计模式,这些设计模式以程序片段库的形式实现。我们发现,当非常少的候选程序满足其类型约束时,Mason表现良好;当这种情况不成立时,我们的扩展可以显著提高Mason的性能。我们认为Mason在使用设计模式合成多类面向对象程序方面迈出了重要一步。
英文摘要:
Object-oriented programs tend to be written using many common coding idioms, such as those captured by design patterns. While design patterns are useful, implementing them is often tedious and repetitive, requiring boilerplate code that distracts the programmer from more essential details. In this paper, we introduce Mason, a tool that synthesizes object-oriented programs from partial program pieces, and we apply it to automatically insert design patterns into programs. At the core of Mason is a novel technique we call type- and name-guided synthesis, in which an enumerative solver traverses a partial program to generate typing constraints; discharges constraints via program transformations guided by the names of constrained types and members; and backtracks when a constraint is violated or a candidate program fails unit tests. We also introduce two extensions to Mason: a non-local backtracking heuristic that uses execution traces, and a language of patterns that impose syntactic restrictions on missing names. We evaluate Mason on a suite of benchmarks to which Mason must add various well-known design patterns implemented as a library of program pieces. We find that Mason performs well when very few candidate programs satisfy its typing constraints and that our extensions can improve Mason's performance significantly when this is not the case. We believe that Mason takes an important step forward in synthesizing multi-class object-oriented programs using design patterns.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。