Seven code taste recognition tools [Overview]

Source: Internet
Author: User
Tags checkstyle

Code smell detection tools (csdt)It can be applied to both the software development stage and the software maintenance stage. Currently, most ides integrate automatic or semi-automatic refactoring tools,According to a survey by foreign researchers, there are not many people who actually use refactoring tools in software development and maintenance. One of the important reasons is that they do not know when to refactor, that is to say, the timing of reconstruction is not allowed.Therefore, automatic identification of reconstruction timing has great practical value. A lot of code taste itself is the indicator of refactoring timing. If you can automatically discover the taste of the Code, it indicates that there are some inappropriate design schemes or program code in the code, implementing refactoring at this time will help improve the code quality.

Currently, most csdt cannot implement automatic refactoring after discovering the code taste. (among the seven tools to be introduced, only jdeodorant provides the refactoring function ), fortunately, modern ide comes with the refactoring function. Although many refactoring tasks require user participation, they only require semi-automatic refactoring, but this is much better than manual refactoring. Manual reconstruction has two main problems:

(1) Low reconstruction Efficiency. Especially for some complicated refactoring, if we follow the example in the Martin Fowler book step by step, the efficiency is very low, making refactoring a non-creative job that consumes a lot of time and energy, and it is impossible to draw a line, not available.

(2) Human restructuring is prone to mistakes. As long as the program itself is correct and can pass strict correctness and reliability tests, the results of automatic reconstruction are often more accurate than those of manual reconstruction, the quality of manual reconstruction depends on the experience of the reconstruction personnel. If you are not careful, there will be errors or incomplete reconstruction.

This article will give a brief introduction to the seven csdt (if you have time, I will describe these tools in detail in subsequent blogs) and provide a download link, you can try to use unused children's shoes. You are also welcome to share your experiences with Sunny, especially your opinions and suggestions on these tools, this is very helpful for Sunny's current research work ,.

[Note: if you do not understand the meanings of these codes, see:22 Code flavors (Martin Fowler and Kent Beck), URL: http://blog.csdn.net/lovelion/article/details/9301691 .]

 

(1) checkstyle

URL: http://checkstyle.sourceforge.net/

Checkstyle is a well-known static code analysis tool that helps programmers compile Java code according to some code standards. It has many built-in rules, you can verify that Java code complies with these predefined rules. Checkstyle can detect four code flavors: large class, long method, long parameter list, and duplicated code.

 

(2) decor

URL: http://www.ptidej.net/research/designsmells/

Designed and developed by Moha and others, decor defines a set of methods used to automatically detect design and code taste (also known as anti-pattern ). They use custom languages to describe the eight code flavors (data class, large class, long method, long parameter list, message chains, refused bequest, speculative generality, tradition breaker ), the templates are used to automatically generate their detection algorithms. Finally, these algorithms are verified based on precision and recall. These algorithms are implemented in decor for software analysis. Decor is not only the name of the method proposed by Moha, but also the name of the Code taste detection tool they developed.

[Note: To obtain the decor installer, you must send an email to the author (ptidejteam). Email Address: [email protected].

 

(3) iplasma

URL: http://loose.upt.ro/iplasma/

Iplasma is an integrated platform for evaluating the quality of object-oriented systems. It involves model extraction, high-level measurement analysis, and many other aspects. Iplasma is used to detect some pre-defined code problems. These problems are divided into three types: identity disharmonies, collaboration disharmonies, and classification disharmonies ), for more information about these problems, seeObject-oriented metrics in practice: using software metrics to characterize, evaluate, and improve the design of object-oriented systemsThis book describes many of these issues, such as duplicated code (significant duplication in iplasma), God class, feature envy, and refused bequest. Of course, iplasma does not detect all problems in object-oriented metrics in practice. In object-oriented metrics in practice, identity disharmonies includes God class, feature envy, data class, brain method, brain class and significant duplication, collaboration disharmonies include intensive coupling, dispersed coupling and implicit surgery, classification problem (classification disharmonies) including refused parent bequest and tradition breaker. If you are interested in these flavors and their detailed descriptions, take a look at them.Refactoring: improving the design of existing codeAndObject-oriented metrics in practice: using software metrics to characterize, evaluate, and improve the design of object-oriented systemsThese two books.

 

(4) infusion

URL: http://www.intooitus.com/inFusion.html

Infusion is a commercial version of iplasma. Therefore, infusion is more powerful than iplasma. However, because it is a commercial software, many features can be used only after you buy the official version, and the price is not cheap, is the latest price list, the price unit is Euro, Euro! Infusion can detect more than 20 code flavors and code defects. Among the seven tools described in this article, it is the most, but it also requires money, the code that it can detect includes repeated code, broken encapsulated classes (such as data classes or omnipotent classes), highly coupled methods and classes, and some poorly designed class inheritance structures.

 

(5) jdeodorant

URL: http://www.jdeodorant.com/

From an academic point of view, jdeodorant is a powerful tool that gave birth to many high-level research papers. It is an Eclipse plug-in that can be used to automatically identify the feature envy, God class, long method, switch statement (called type checking in jdeodorant) and other code flavors in Java programs. For identified code problems, jdeodorant will provide users with a variety of suitable refactoring solutions and sort them according to their impact on the design, then, the sorting result is displayed to the developer for selection, and the selected refactoring means can be automatically implemented.

 

(6) PMD

URL: http://pmd.sourceforge.net/and https://github.com/pmd

It has a high reputation in the field of static code analysis. It can scan the Java source code and find potential problems or possible bugs in the Code, such as dead code (dead code ), empty try/catch/finally/switch statement (empty statement block), unusedlocal variables or parameters (unused local variables or parameters) and duplicated code (repeated code. It can also detect some code flavors, such as large class, long method, long parameter list, and duplicated code. It allows users to set threshold values for some probe metric factors when detecting the taste of these codes, for example, the number of lines of code in large class and long method, the number of method parameters in long parameter list, and the number of duplicated codes in duplicated code can be set by the user.

 

(7) stench blossom

URL: http://people.engr.ncsu.edu/ermurph3/tools.html

Stench blossom is a taste recognition tool that provides an interactive visual environment. It can quickly provide programmers with a high-level view of the Code taste and the source of the taste. Stench blossom is also an Eclipse plug-in that provides programmers with three different views. These three views gradually provide more information about the taste of the Code in a visualized manner. It finally returns a comprehensive feedback result visually. In IDE, the code unit is expressed in the form of a petal chart. The size of the petal is proportional to the "intensity" of the existing taste in a generation of code units, that is to say, the more the existing code tastes, the larger the corresponding petals. The only possible way to look for the taste of the code is to manually review the source code, mainly to analyze the big petals that have the taste of the Code. Stench blossom can detect eight code flavors: Data clumps, feature envy, instanceof, large class, long method, message chains, switch statement, and typecast. Some of these flavors do not belong to the 22 classic code flavors defined by Martin flower.

 

Table 1 summarizes some of the basic features of these seven tools. It is not difficult to see that all tools can identify the taste of Java code, some tools can recognize the taste of code in C/C ++. Some tools are released as standalone and some are released as Eclipse plug-ins; only jdeodorant provides the refactoring function. Some tools can only detect the taste in the code, but do not identify the taste. See table 1 for details:

Table 2 collects statistics on the taste of the Code that these seven tools can detect. As a commercial tool, infusion can identify up to 12 code flavors ), followed by iplasma (11 types ).

Table 2 contains 21 code flavors, but not all of them are the 22 Code flavors that Martin Fowler defined in refactoring. The seven tools described in this article can recognize more than half of the taste, and do not know whether the new version can recognize more flavor. If you can recognize more flavors (in addition to those 21, there are some other code flavors), and the recognition speed is also too high, I think we should be able to develop more powerful code taste recognition tools ,.

Because different code taste recognition tools have different implementation principles, the recognition results of different tools are not necessarily the same for the same code taste, some foreign scholars have compared the accuracy of these tools. Different tools may have some advantages for some taste, but may not be the best for others. There is a lack of unified standards and specifications, which is also a problem faced by the current Code taste recognition. There are fewer people engaged in research and tool development in China, many enterprises do not pay enough attention to code quality. As a result, the promotion and use of code taste recognition tools are not very powerful, and they hope to improve in the future.

In addition to the above seven tools, there are also some tools and methods used to detect the taste of code. For example, codevizard (based onObject-oriented metrics in practiceThe detection rules defined in this book), incode (Eclipse plug-in based on infusion), excop (. net), Analyst (for Java, commercial software), jcosmo (for Linux), clonedigger, and conqat (for clone detection). Among them, clone detection tools should be the most, sunny plans to organize a special blog post to introduce common clone detection tools.

All of the tools described in this article can be used in combination with the refactoring menu in eclipse. If you have any questions about code taste recognition and refactoring, please contact Sunny!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.