论文标题
jhotdraw尊重良好风格的定律吗?
Did JHotDraw Respect the Law of Good Style?: A deep dive into the nature of false positives of bad code smells
论文作者
论文摘要
开发人员需要持续努力,以提高代码的质量,如果他们想保持生产力。因此,强调可以从重构中受益的代码位置的工具非常需要。此类位置的最常见名称是“不良代码气味”。许多工具提供了这种质量反馈,并且有大量相关研究。但是,所有这些工具,包括基于机器学习的工具,仍然会产生误报。向开发人员显示的每一个假阳性都会给她带来认知负担,因此应避免。文献讨论了公制阈值的选择,这种判断的一般主观性以及与有意识的设计选择“设计思想”的关系。为了检查误报以及不良气味和设计思想之间的关系,我们设计并进行了探索性案例研究。尽管以前的研究提出了广泛的概述,但我们选择了一个狭窄的环境来获得更深入的见解:框架jhotdraw的设计是如此精心设计,以至于大多数气味警告预计将是误报。然而,“好风格的法则”(更名为“ Demeter定律”)是一项相当限制的设计规则,因此我们仍然期望发现一些潜在的不良气味,即违反这种“法律”。这种组合导致了1215种潜在的气味,其中最多42个是真正的阳性。我们发现了闻起来的通用和特定的设计思想。我们对这一决定的信心从高到很高。我们惊讶地意识到气味定义本身需要制定建设性设计思想。最终,我们发现某些气味是语言局限性的结果,人们可以引入辅助建设性设计思想来补偿它们。明确地做出了非常精心的决定,这一决定是否实际上是真正的阳性。为此,我们采取了三种质量,气味可能会对负面影响,我们讨论了建议的重构的结果。如果我们确信我们发现了一个假阳性,我们将描述与设计思想的关系。意识到,不仅一般设计思想,而且特定的设计思想对潜在气味是真正的积极影响,从科学问题(“气味的真实定义?”)变成了工程问题(“我们如何将设计思想的定义纳入气味定义?”)。我们建议将适应点添加到气味定义中。然后,较高的层可能会使气味适应特定环境。适应后,该工具可以不断提供独特而精确的质量反馈,从而减少开发人员的认知负荷并防止习惯。此外,讨论潜在气味的模式可用于详细说明更多的真实和假气味。最后,遵循基于机器学习的气味检测也应考虑设计思想的迹象。
Developers need to make a constant effort to improve the quality of their code if they want to stay productive. Tools that highlight code locations that could benefit from refactoring are thus highly desirable. The most common name for such locations is "bad code smell". A number of tools offer such quality feedback and there is a substantial body of related research. However, all these tools, including those based on Machine Learning, still produce false positives. Every single false positive shown to the developer places a cognitive burden on her and should thus be avoided. The literature discusses the choice of metric thresholds, the general subjectivity of such a judgment and the relation to conscious design choices, "design ideas". To examine false positives and the relation between bad smells and design ideas, we designed and conducted an exploratory case study. While previous research presented a broad overview, we have chosen a narrow setting to reach for even deeper insights: The framework JHotDraw had been designed so thoughtfully that most smell warnings are expected to be false positives. Nevertheless, the "Law of Good Style", better known as the "Law of Demeter", is a rather restrictive design rule so that we still expected to find some potential bad smells, i.e. violations of this "Law". This combination led to 1215 potential smells of which at most 42 are true positives. We found generic as well as specific design ideas that were traded for the smell. Our confidence in that decision ranged from high enough to very high. We were surprised to realize that the smell definition itself required the formulation of constructive design ideas. Finally we found some smells to be the result of the limitation of the language and one could introduce auxiliary constructive design ideas to compensate for them. The decision whether a potential smell occurrence is actually a true positive was made very meticulously. For that purpose we took three qualities that the smell could affect negatively into account and we discussed the result of the recommended refactorings. If we were convinced that we had found a false positive, we described the relationships with design ideas. The realization that not only general design ideas but also specific design ideas have an influence on whether a potential smell is a true positive turns the problem of false positives from a scientific problem ("What is the true definition of the smell?") to a engineering problem ("How can we incorporate design ideas into smell definitions?"). We recommend to add adaptation points to the smell definitions. Higher layers may then adapt the smell for specific contexts. After adaptation the tool may continuously provide distinct and precise quality feedback, reducing the cognitive load for the developer and preventing habituation. Furthermore, the schema for the discussion of potential smells may be used to elaborate more sets of true and false smell occurrences. Finally, it follows that smell detection based on machine learning should also take signs of design ideas into account.