zoukankan      html  css  js  c++  java
  • [论文笔记] A Survey of Software Refactoring(TOSE, 2004)第一部分

    Time:8 hours
    Timespan:Dec 8 – Dec 14 (杂事多,断断续续看了一周,终于把这篇综述看完了)

    Tom Mens, Tom Tourwé (2004). A Survey of Software Refactoring. IEEE Transactions on Software Engineering, 30: 2. 126-139 February (gs:521)

         这篇论文的作者Tom Mens1999年获得博士学位,现在是比利时蒙斯大学(University of Mons)的full professor,主要研究“formal foundations and automated tool support for software engineering”(特别是software evolution等),论著颇丰。在Google Scholar里搜“refactoring”,这篇论文排在第五位,且出版时间相对较迟,应该是该方向截止目前最新的一篇综述。

        这篇综述针对软件重构(software refactoring),篇幅13页半,引用了111篇文献。全文分为8个部分,第一部分Introduction,第二部分是一个贯穿全文的重构实例(将原有设计重构为vistor模式),最后部分Conclusions,正文其他五个部分结构如下:

      • 3. Refactoring Activities。 将重构的过程分为了六个步骤(或活动),包括确定哪些地方需要被重构、应适用何种重构方法等。
      • 4. Refactoring Techniques and Formalisms。主要各种技术(包括assertion & graph transformation)与形式化方法对重构各个步骤的支持。
      • 5. Types of Software Artifacts。"Software Artifact",中文翻译为"软件工件",文中提到了Program、Design、Software Requirement这三种的重构。
      • 6. Tool Support。讨论了重构工具应支持的特性。
      • 7. Process Supoort。介绍重构与Software Reengineering、Agile Software Development、Framework-Based or Product Line Software Development的关系。

        下面是详细论文笔记:

    1. (S1) 常识性概念
    (1) 软件开发最大的成本是在软件维护(software maintenance) [1] [2] [3] (原文中的索引,下同)
    (2) restructuring: "the transformation from one representation form to another at the same time relative abstraction level, while preserving the subject system's external behavior (functionality and semantics)"
          refactoring: "basically the object-oriented variant of restructing ",因此refactoring是restructuring的一种。 Refactoring最早由Opdyke在他的博士论文中提出(1992年,UIUC)。Martin Fowler对refactoring的定义是:"the process of changing a [object-oriented] software system in such a way that it does not alter the external behavior of the code, yet improves its internal structure".
    (3) 不同语境下的restructuring/refactoring:
          software evolution: improve the quality of the software
          reengineering: examinaion and alteration of a subject system to reconstitute it in a new form and the subsequent implementation of the new form

    2. (S2) 介绍了一个"Document Hierarchy"的例子,通过20几个"primitive refactorings",将其重构为Visitor模式。
    这里介绍了primitive refactoring与composite refactoring这两个概念,后者具有更大的粒度。

    3. (S3) 介绍了重构过程的六个步骤(活动),依次为:

      • 哪里需要被重构?(识别需要重构的地方)(S3.1)
        • (S3.1)中作者综述了现有方法和工具,包括Daikon Tool(通过自动检测程序不变量)、bad smells(most widespread approach)、可分析duplicated code的clone analysis tool等。 (对应的具体文献见原文,由于我目前并不专门研究这个方向,暂不跟进这些文献,下同)
      • 使用何种重构方法?(确定应该使用的重构方法)(S3.1)
        • 也在(S3.1)中提到,包括Flowler将bad smell与refactoring方法关联、本文作者提出的基于logic meta programming的被自动化方法、基于object-oriented metrics的方法、及visualization mechanism等。
        • 作者提到使用何种refactoring,高度依赖于特定的应用领域。对于web-based software, “where and why”to refactor,可参考书籍《Core J2EE Pattern》。
      • 确保重构“preserve behavior”(S3.2)
        • behavior perservation的概念最早由Opdyke提出:"for the same set of input values, the resulting set of output values should be the same before and after the refactoring",即"preservation of input-output behavior"
        • 但在许多应用领域中,满足上述输入输出的条件还不够。比如对实时软件,执行的时间长短就很关键,在嵌入式领域,重构还要考虑内存空间与电量消耗等。
        • 原文索引中的[23][24]提到了有趣的例子:不改变behavior的重构却不能通过部分现有的测试(即通过现有测试并非是重构的必要条件)。
        • 小结:确保行为一致的方法,有从实用主义(pragmatic)出发,也有用形式化方法来证明(如对于Prolog这类语言)
      • 进行重构
      • 重构是否有效?(评估重构的效果,可以从软件的复杂性、可理解性、可维护性,或者过程的生产率、成本等多方面进行)(S3.3)
        • 可以根据针对的quality attribute来对重构进行分类,比如可以是:remove code redundancy、raise the level of abstraction、enhance the resuability等
        • misconception: "improving the program structure has a negative effect on the program performance"。作者在(S3.3)引用了几篇文献对此观点进行了驳斥。
        • 度量、评估重构对质量属性影响的方法有:software metrics、empirical measurements、controlled experiments、statistical techniques等,文中介绍了相关文献。
      • 维护重构后代码与其他软件工件(各类文档等)的一致性(S3.4)
        • 代码重构后,要维护不同抽象层次的软件工件(如设计文档、需求文档等),也要维护相同层次的(如单元测试)

    未完待续[论文笔记] A Survey of Software Refactoring(TOSE, 2004)第二部分


  • 相关阅读:
    C#Winform中treeView控件使用总结
    转:vs发布window应用程序时出错:未能签名 ...setup.exe
    C# 常见集合之前的转换
    开发者眼中的Spring与JavaEE
    运行库到底做了什么?
    C++, Java和C#的编译、链接过程解析
    转载一篇将C/C++ 与lua混合使用入门讲的比较好的文章
    路会越走越窄的
    [DBNETLIB][ConnectionOpen(Connect()).]SQL Server 不存在或拒绝访问 数据库错误 解决办法总结
    Linux学习路线指南
  • 原文地址:https://www.cnblogs.com/yuquanlaobo/p/2280380.html
Copyright © 2011-2022 走看看