Introduction
Code writing style mainly includes variables, methods, classes and other language entities of the naming and layout of the code of two aspects. Evaluation of the quality of the code depends not only on the algorithm and data structure, code layout is an indispensable aspect. With the expansion of the scale of modern software, team development is unavoidable, good code writing style enhances code readability and maintainability, enhances the efficiency of teamwork.
JBuilder is known as the Java Aircraft Carrier level development tool, the current highest version is 10, named Jbuilderx. This article focuses on how to beautify the code in Jbuilderx, format the layout of the code typesetting, and also introduce some practical tips for Jbuilderx to speed up code writing.
Code Landscaping Tools
There are already a lot of code beautification tool software, more famous have indent, Astyle, Jalopy, Sourceformatx, which SOURCEFORMATX is a multi-language code beautification tool. However, these tools are not well integrated with development tools, are not easy to operate, are not powerful enough, or are not specific to the Java language. Jbuildex integrates a powerful code layout formatting tool that you can use to beautify your code after you've written it. It can do the following 7 aspects of the code to format work:
1 Indentation: Java code in the "{}" division of the different code subdomain, the inner domain than the outer domain needs to indent some, so that the code has a sense of hierarchy, through the tool can define the layer relative to the outer code indentation of the number of spaces, the TAB key corresponding to the number of spaces;
2) Branch: class definition, method definition, and control code, such as if. else, while, try ... Catch, and so on, have the corresponding "{}" to organize its area of code, you can specify whether "{" and "}" is a different line;
3 space: Specified in operator, parenthesis "()", bracket "[]", semicolon ";" Whether a space is required between the symbol and the operation code;
4 Blank line: Allows you to specify where in the code you want to add blank lines and lines, so that different code fields to distinguish between more clearly;
5 Line Alignment: Specifies the maximum number of columns for the line of code, and the line that exceeds the number of columns is intelligently split into multiple lines, and only lines of code that contain an operator or a comma can be wrapped. You can specify whether the line-break point is before or after these symbols, and you can also set the alignment of multiple lines after the line break;
6 code generation Rules: Control automatic event handle, variable visual field and JavaBean instantiation code generation rules;
7 Import Code optimization rules: Control the import code introduced in the class of packages and classes to generate and their ordering order to optimize the import code snippet.
After creating the Java project, click the right mouse button on the engineering panel's engineering file (XXX.JPX) on the top left corner of the main window, and click the following operation to bring up the Code beautification tool settings interface:
Select Properties-> to select Fomatting in the tree on the left side of the pop-up window to get the Action window interface as shown in Figure 1:
Figure 1. Code Formatting window
The right side of the window has 7 page tabs that correspond to the 7 aspects of the code settings mentioned above. There are several settings on the left of each settings page, and a preview of the code formatting on the right, so you can instantly see how the settings affect the layout of your code. In the next section, I'll show you a concrete example of how to use this Code landscaping tool.