Changing Programs Correctly: Refactoring with Specifications

Changing Programs Correctly: Refactoring with Specifications
复制标题

正确更改程序:按照规范进行重构

DOI:
10.1007/11813040_33
复制
发表时间:
2006
期刊:
ArXiv
影响因子:
--
通讯作者:
Peter Müller
Peter Müller
中科院分区:
--
文献类型:
--
作者:
F. Bannwart;Peter Müller

文献摘要

被引文献

相似文献

重构改变了代码的内部结构,而不改变其外部行为。对于非平凡重构,外部行为的保留取决于程序的语义属性,这些属性在应用重构之前很难自动检查。因此,现有的重构工具要么根本不支持非平凡的重构,要么迫使程序员依赖(通常是不完整的)测试套件来检查他们的重构。 本文中提出的技术允许人们显示即使对于复杂的重构也能保持外部行为。对于一个给定的重构,我们证明了一次和所有的重构是一个等价的转换,提供重构程序满足一定的语义正确性条件。这些条件可以作为断言自动添加到重构的程序中,并在运行时检查或静态验证。我们的技术允许工具安全地应用复杂的重构,重构通过生成断言自动改进程序文档。
Refactorings change the internal structure of code without changing its external behavior. For non-trivial refactorings, the preservation of external behavior depends on semantic properties of the program that are difficult to check automatically before the refactoring is applied. Therefore, existing refactoring tools either do not support non-trivial refactorings at all or force programmers to rely on (typically incomplete) test suites to check their refactorings. The technique presented in the paper allows one to show the preservation of external behavior even for complex refactorings. For a given refactoring, we prove once and for all that the refactoring is an equivalence transformation, provided that the refactored program satisfies certain semantic correctness conditions. These conditions can be added automatically as assertions to the refactored program and checked at runtime or verified statically. Our technique allows tools to apply even complex refactorings safely, and refactorings automatically improve program documentation by generating assertions.