Code optimization tool

xiaoxiao2021-03-13  186

Copyright Notice: You can reprint anything, please sure to indicate the original source and author information and this statement by hyperlink. Http://www.chedong.com/tech/undent_tools.html

Keywords: pretty print indent Perlty Pydent AStyle Htmltidy Source Code Beautifier

Summary: The purpose of writing this article is nothing more than 2:

If the predecessor's indentation is very unlined, it affects the code reading speed of the current maintainer. New project code (writing in what editing environment) can adapt to the company's indentation specification, which can facilitate communication between developers.

If you can find it now, you need to see you need to see the last: The document in the corresponding kit will have more detailed instructions.

C, C C # ==> indent AStylejava ==> AStyle Jalopy Jacobe Importscrbberphp ==> phpcodebeautifierperl ==> PerltiDython ==> Pydent

ASP ==> VBSBEAUT

The programmer should be good at communicating, the meaning of code beautification is to reflect the respect of the developer's respect for others, using good coding conventions to make source code, easy to read, accurate, more intuitive and more intuitive and other language agreement, thus Better communication between programmers.

There is a statistical indicate that the indentation code can improve the efficiency of code reading more than 40%, and the other statistics are more than 70% of software development work is the code for maintenance, so the format of past code is often the system reconstruction ( The first step in Refactoring. The use of the PRETTY Print Program allows the basic code indent specification to become a system that is easier to perform.

In addition, if the servant as a sector code specification should also understand the programmaker is not a machine, it is almost impossible when writing code. Tool-based volume formatting and organizing tools for easy configuration Import / export mechanisms Develop a unified indentation specification is a truly operability.

Introduction to the code beautifying tools for open source code

Tool Name Applicable Language Introduction Installation / Using Indent Cindent is a standard tool for code beautifying tools Indent is a standard tool included with GCC, Indenter, Indenter, Indenter, Indenter, Indenter, Indenter, Indenter, Indenter File] Perltidy Perl Perltidy itself is also downloaded by Perl: Perl makefile.pl; make; make install perltix [options] file1 file2 file3 ... (Output Goes to file1.tdy, file2.tdy, file3.tdy,. ..) Perltix [options] file1 -o outfile perltix [Options] file1 -st> Outfile Perlty [options] OutfileAStyleC C Java (PHP) A speed fast C / C / Java source code beautifying tool. AStyle is better than Indenter: ANSI Java Linux ... You don't have to remember the complex indentation specific options. After downloading the source code, make, generate an ASTYLE executable AStyle [options] Beautified AStyle [options] foo.cpp bar.cpp [...] AStyle --Style = ANSI * .CPP I tried It is also very effective in formatting the PHP program (of course, the pure PHP code that is not mixed with the HTML code). Jalopyjava Powerful Java Code Format Tool, in addition to the standard interface, command line tool, can also be used as a plugin such as Ant JBuilder Eclipse JDeveloper and provides an API from http://prdownloads.sourceForge.net/jalopy/ download and Refer to the corresponding installation document PydenTPythonPythius contains 2 tools: PydenT: Code Indent Tool PyStat: After the code statistics tool download source code unpack: run "python setup.py build" Run "python setup.py install" htmltidyhtml / xmlhtml code Error correction tools can help your HTML code better in line with W3C specification, now known as Tidy, because it is not only used in HTML, but also is also available for XHTML XML formatting. However, JSP is not suitable for ASP PHP JSP, which makes the code landscaping the source code. -WRAP 132 -F% F.ERR% f

Option Description:

-RAW: Does not modify Chinese characters (Output Values ​​Above 127 without conversion to entities)

-i indend default HTML Press 2 space indentation

-m covers the original file

-u Force all HTML marker uppercase (this can not add)

-WRAP page code width is greater than 132 lines forced wrap

-f% f.err outputs an error to the "corresponding file name .ERR" file

HTMLTIDY supports XML format beautification:

Tidy-xml -imq web.xml

Tidy-xml -imq build.xml

Other tool introductions:

PHP Code Beautif Tool phpcb: PHP Code Beautifier has a command line version, and there is a code viewer with a graphics interface. Http://www.phnedit.net/products/phpcodebeautifier/java's code beautification tool If it is specifically for Java code, Jacobe is also a good choice, it is default, which contains a format that completely followed by Sun's code specification. Chemical configuration file. And even Jindent This commercial code finishing tool for better results.

Importscrbber: Java Import declarations to make the reference java.util. * Such references into a single reference, and help delete a reference that no longer needs. http://importscrubber.sourceforge.net/

Introduce these tools can be found here: Jacobe Jindent JxBeautifier ... http://directory.google.com/top/computers/programming/languages/java/development_tools/code_beautifierrs/

Use the command line tool to implement the batch modification of the code

Under Windows 2000: Directory traversal and file filtering and command execution are implemented with the for command, for example: for / R% f in (* .java) do school --style = java% f for / R% f in (* .htm * ) Do Tidy -raw -imq -wrap 132 -F% F.ERR% f for / R% f in (* .asp) do vbsbeaut.exe -i -s4% F Linux: Execute with Find -exec, for example: Find ./ -Name * .java -exec ASTYLE --Style = ANSI {} /;

So don't be confused by many commercial software, when faced with thousands of source files, it is also a very important feature based on whether ordered batch operations.

Tool plugin for Ide development environments such as Eclipse

More and more IDE development environments contain code beautification, but some are still unlikely to be strong, and if there is eclipse in developers, some of the loyal users of JBuilder, how to make them easily abide by code Standardize? The answer is to use all JALOPY to develop the environment for these mainstream IDE development environments. JALOPY: Java code beautification tool: http://jalopy.sourceforge.net/ Eclipse Plug-in: http://jalopy.sourceforge.net/plugin-eclipse.html Checkstyle: Java code code specification (indent, naming) check Tool http://checkstyle.sourceforge.net Eclipse Plug-in: Eclipse Checkstyle Plug-in

Installation: Plug-in installation as Eclipse is very convenient, unpackage to the Eclipse / PLUG-IN / directory to restart Eclipse:

Configuration: Jalopy: Windows ==> Jalopy Preference Configure Import / Export in General Mengers, Checkstyle: Windows ==> Perference ==> Checkstyle Configuration Import / Export is the import / export function of the configuration interface right It greatly reduces the study time for developers for the above tools. For most developers, there is no need to understand all the option configurations, just know that the standard configuration is imported. I often use: Jalopy: In addition to the original format option, in addition to the original format option, the Source => Orgenize Imports that Eclipse itself can be reached in addition to the original Format option. Imports srubber The same effect. Checkstyle is a very complex code style check: including indentation, naming, etc., so the default is disable, startup checkstyle needed for a project, the project's Properties ==> CheckStyle ==> Enable.

Moreover, these tools include extensions for Ant, which can be easily added to the ANT script for automatic code finishing / statistics.

Reference:

GNU Coding Standards http://www.gnu.org/prep/standards_toc.html

Code Conventions for the Java (TM) programming language http://java.sun.com/docs/codeconv/html/codeconvtoc.doc.html

PHP Coding Standard http://alltasks.net/code/php_coding_standard.html

Perl style http://www.Perldoc.com/perl5.6.1/pod/perlstyle.html PB: Perl / JavaScript Beautifier

http://www.arachnoid.com/lutusp/ftp/cgi/pb.txt

HTML XML XHTML CSS ... http://www.w3c.org C-C Beautifier How-to:

http://www.tldp.org/howto/c-c beautifier-howto/

VBScript code specification http://msdn.microsoft.com/library/en-us/script56/html/vbscodingconventions.asp

VBSBeaut code finishing tool http://www.daansystems.com/vbsbeaut/

Dependency analysis between Java components http://www.clarkware.com/software/jdepend.html

Code check http://www.thecortex.net/clover/index.html

More XP Tools http://directory.google.com/top/computers/programming/languages/java/coding_standards/ http://www.xprogramming.com/software.htm http://www.qsm.com/codecounters .html

Attachment: Why HTMLTIDY is not suitable for reformatting the JSP PHP ASP and other HTML embedded scripting languages

Some errors that cannot be parsed are actually caused by the code irregular.

"<" In JavaScript, for example, for (i = 1; i > But like this code: <% = infoForm.getphoto ()%> width = 120> due to The beginning of the property is not <%, so IMG has no end error htmltidy default is completely complemented by the code, and many HTML code is in the included file. Moreover, HTMLTIDY has a problem with Chinese code recognition (currently only supporting BIG5):

Why is embedded code difficult to maintain? After all, it is more complicated to the unregistered HTML syntax inspector than a language parser. For example, such as this code: ";?>

This form of code, beautification tools must also understand HTML syntax and PHP syntax, so most format tools are for a language, or formatted to the program part of embedded scripts, or only formatted for pure HTML. Only large Virsual Age, Forte contained JSP code beautification, and the Slickedit is a large commercial text editor.

Solve: For the format of the HTML section of the program-containing JSP ASP, it is best to use a dedicated HTML editing tool Dreamweaver (≥4) and the formatting tool in FrontPage (≥2000). For example: For FrontPage tools from the menu ==> Web option ==> HTML Source Mode Male Select "Re-format Source Codes using the following rules".

In summary, the embedded scripting language with HTML and procedures is itself a very bad development habit. Separation of data / performance / logical from the long-term technology to implement data / performance / logic is a mode for large-scale development.

For the current large amount of ASP PHP JSP applications, I still find some tools on Google, believe in Homesite, etc. In fact, the VBSBeautifier mentioned earlier is actually called Perl 5.8 on Windows.

A code beautifying tool for ASP: vbsbeaut http://www.daansystems.com/vbsbeaut/

A tool for the ASP JSP PHP editing and the code beautification feature: bphtmlhttp://www.bphtml.com/ A Java-based HTML editor, embedded C C Java JavaScript Perl class C language code beautifier :

http://www.arachnoid.com/arachnophilia/index.html Beautifier highlights and indents source code using highlight configuration files (which are similar to Ultraedit highlighting files). As such, it supports C, C #, Java, Perl, PHP, Pascal, Lisp, Mumps, Eiffel, Euphoria, and x86 assembler, amongst others.http: //www.beautifier.org/

Trita is a source code beautifier which learns your personal formatting style by examining examples of your code http://www.trita.com/ support:. Java, Javscript, CSS, JSP, HTML, ASP, Lisp, Delphi, C #, C , PHP, Perl, Python, And SQL. Original source: http://www.chedong.com/tech/indent_tools.html

转载请注明原文地址:https://www.9cbs.com/read-129189.html

New Post(0)