A Feature Envy Detection Method Based on Data Flow Analysis

碩士 === 國立臺北科技大學 === 資訊工程系研究所 === 105 === Feature Envy is a code small indicating that a method (function) seems to be more interested in a class other than the one it is actually in. Such a method performs computations for another class, takes on responsibilities beyond its own, and violates the fun...

Full description

Bibliographic Details
Main Authors: Bo-Hong Li, 李柏鋐
Other Authors: Chien-Hung Liu
Format: Others
Language:zh-TW
Published: 2017
Online Access:http://ndltd.ncl.edu.tw/handle/e2h88q
Description
Summary:碩士 === 國立臺北科技大學 === 資訊工程系研究所 === 105 === Feature Envy is a code small indicating that a method (function) seems to be more interested in a class other than the one it is actually in. Such a method performs computations for another class, takes on responsibilities beyond its own, and violates the fundamental object-abstraction principle that an object should offer computations for its own attributes. When Feature Envy appears, object cohesion may be decreased and object coupling increased, signifying a degradation in code quality. Hence, several Feature Envy detection approaches have been proposed. However, current approaches can only determine whether a method is of Feature Envy. In case that the method is lengthy, it can be difficult for the user to pinpoint the statements (inside the method) that are guilty for Feature Envy. Furthermore, when a method uses too many classes and/or mixes several kinds of behaviors, current approaches could easily be fooled. This thesis proposes a Feature Envy detection method called FEED (FEature Envy Detection) that uses dataflow analysis to analyze the variable definitions and uses in each statement. Such information is then used to determine whether a particular statement overly uses another class. In comparison to previous approaches, our approach offers a better detection granularity: whether a statement is of Feature Envy can be detected. In addition, our approach provides a better detection accuracy.