首页 | 官方网站   微博 | 高级检索  
     

融合结构与语义特征的代码注释决策支持方法
引用本文:黄袁,贾楠,周强,陈湘萍,熊英飞,罗笑南.融合结构与语义特征的代码注释决策支持方法[J].软件学报,2018,29(8):2226-2242.
作者姓名:黄袁  贾楠  周强  陈湘萍  熊英飞  罗笑南
作者单位:中山大学 数据科学与计算机学院, 广东 广州 510006;国家数字家庭工程技术研究中心, 广东 广州 510006,中山大学 数据科学与计算机学院, 广东 广州 510006;河北地质大学 管理科学与工程学院, 石家庄 050031,中山大学 数据科学与计算机学院, 广东 广州 510006;国家数字家庭工程技术研究中心, 广东 广州 510006,国家数字家庭工程技术研究中心, 广东 广州 510006;中山大学 先进技术研究院, 广东 广州 510006,北京大学 信息科学技术学院 软件研究所, 北京 100871;高可信软件技术教育部重点实验室. 北京大学, 北京 100871,中山大学 数据科学与计算机学院, 广东 广州 510006;国家数字家庭工程技术研究中心, 广东 广州 510006
基金项目:国家重点研发计划(2016YFB1000101);国家自然科学基金(61672545,61402546);广东省科技计划项目(2013B090700009);中山市科技计划项目(2016A1044)
摘    要:代码注释是辅助编程人员理解源代码的有效手段之一.高质量的注释决策不仅能覆盖软件系统中的核心代码片段,还能避免产生多余的代码注释.然而,在实际开发中,编程人员往往缺乏统一的注释规范,大部分的注释决策都取决于个人经验以及领域知识.对于新手程序员来说,注释决策显然成为了一项重要而艰巨的任务.为了减少编程人员投入过多的精力在注释决策上,文章从大量的代码注释实例中学习出一种通用的注释决策规范,并提出了一种新颖的CommentAdviser方法用以辅助编程人员在代码开发过程中做出恰当的注释决策.由于注释决策与代码本身的上下文信息密切相关,因此,从当前代码行的上下文代码中提取代码结构特征以及代码语义特征作为支持注释决策的主要依据.然后,利用机器学习算法判定当前代码行是否为可能的注释点.在GitHub中的10个大型开源软件的数据集上评估了我们提出的方法,实验结果以及用户调研表明代码注释决策支持方法CommentAdviser的可行性和有效性.

关 键 词:代码注释  结构特征  语义特征  机器学习  注释决策
收稿时间:2017/7/18 0:00:00
修稿时间:2017/9/28 0:00:00

Method Combining Structural and Semantic Features to Support Code Commenting Decision
HUANG Yuan,JIA Nan,ZHOU Qiang,CHEN Xiang-Ping,XIONG Ying-Fei and LUO Xiao-Nan.Method Combining Structural and Semantic Features to Support Code Commenting Decision[J].Journal of Software,2018,29(8):2226-2242.
Authors:HUANG Yuan  JIA Nan  ZHOU Qiang  CHEN Xiang-Ping  XIONG Ying-Fei and LUO Xiao-Nan
Affiliation:School of Data and Computer Science, Sun Yat-sen University, Guangzhou 510006, China;National Engineering Research Center of Digital Life, Guangzhou 510006, China,School of Data and Computer Science, Sun Yat-sen University, Guangzhou 510006, China;School of Management Science and Engineering, Hebei GEO University, Shijiazhuang 050031, China,School of Data and Computer Science, Sun Yat-sen University, Guangzhou 510006, China;National Engineering Research Center of Digital Life, Guangzhou 510006, China,National Engineering Research Center of Digital Life, Guangzhou 510006, China;Institute of Advanced Technology, Sun Yat-sen University, Guangzhou 510006, China,Software Engineering Institute, School of Electronics Engineering and Computer Science, Peking University, Beijing 100871, China;Key Laboratory of High Confidence Software Technologies of Ministry of Education. Peking University;, Beijing 100871, China and School of Data and Computer Science, Sun Yat-sen University, Guangzhou 510006, China;National Engineering Research Center of Digital Life, Guangzhou 510006, China
Abstract:Code comment is quite important to help developer review and comprehend source code. Strategic comment decision is desired to cover core code snippets of software system without incurring unintended trivial comments. However, in current practice, there is a lack of rigorous specifications for developers to make their comment decisions. Commenting has become an important yet tough decision which mostly depends on the personal experience of developers. To reduce the effort on making comment decisions, in this paper, we try to learn an unified commenting regulation from large of commenting instances.We propose a novel method, CommentAdviser, to guide developers where to comment in source code. Since making comment is closely related to the context information of source code themselves, we identify this important factor for determining where to comment and extract them as structural context feature and semantic context feature. After that, machine learning techniques are applied to identify the possible commenting locations in source code. We evaluate CommentAdviser on 10 data sets from GitHub. The experimental results, as well as a user study, demonstrate the feasibility and effectiveness of CommentAdviser.
Keywords:code comment  structural feature  semantic feature  machine learning  comment decision
点击此处可从《软件学报》浏览原始摘要信息
点击此处可从《软件学报》下载全文
设为首页 | 免责声明 | 关于勤云 | 加入收藏

Copyright©北京勤云科技发展有限公司    京ICP备09084417号-23

京公网安备 11010802026262号