Team‘s code standards in the bate sprint by FZU Flying Club_Beta Sprint
Catalogues
This assignment belongs to which course | EE308FZ Software Engineering https://bbs.csdn.net/forums/ssynkqtd-04 |
---|---|
Where this assignment is required | https://bbs.csdn.net/topics/617676810 |
Team name | FZU Flying Club |
The goal of this assignment | Help students understand Beta Sprint and promote course project progress |
Other references | None |
1 Naming Style
Class names should use UpperCamelCase. Method names, parameter names, member variables, and local variables should use lowerCamelCase. Constants should be named in all upper case with underscores. The middle bracket is part of the array type; define arrays as follows: String[] args
. If design patterns are used in modules, interfaces, classes, or methods, reflect the pattern in the naming.
2 Constant Definitions
Avoid magic values in the code. Group constants based on their function and maintain them separately. Reuse constants at five levels: cross-application, intra-application, intra-subproject, intra-package, and intra-class. Use enumerated classes for variables with a limited range of values.
3 Code Format
Simplify the use of curly brackets. If there is empty space inside curly brackets, write {}
succinctly without line breaks. Ensure a space between reserved words (if/for/while/switch/do) and parentheses. Maintain a space between the left and right sides of binary or ternary operators. Use a single space between the double slash of comments and the content. Simplify method parameter definition with a space after the comma for multiple parameters.
4 OOP Protocol
Avoid unnecessary object references for static variables or methods. Add @Override
annotation for all override methods. Use Java’s variable parameters for the same parameter types and business meaning. Use equals
method for comparison between objects of the same wrapper class type. Refrain from adding business logic in constructor methods; use an init
method for initialization logic.
5 Collection Handling
Follow rules for hashCode
and equals
. Rewrite hashCode
whenever equals
is rewritten. Rewrite hashCode
and equals
for objects stored in sets. Use appropriate methods for converting sets to arrays and vice versa. Avoid explicit thread creation; use thread pools. Consider performance loss of locks in high concurrency and use lockless data structures when possible.
6 Control Statements
Include break
or return
in each case within a switch
block. Include a default statement even if it contains no code. Always use curly braces in if/else/for/while/do statements. Avoid single-line coding and execute complex statements outside conditional judgments.
7 Annotation
Annotate classes, class attributes, and class methods using Javadoc specification. Use /**content**/
format and avoid // xxx
methods. Annotate all abstract methods with Javadoc. Use Chinese annotations if necessary.
8 Other
Make efficient use of regular expression pre-compile function.
9 Exception Handling
Pre-check and avoid handling RuntimeException
. Distinguish between stable and unstable code. Manually roll back transactions after catching exceptions in transaction code. Ensure caught and thrown exceptions are exact matches or the caught exception is the parent of the thrown exception.
10 Unit Testing
Follow the AIR principles for good unit tests. Tests must be fully automated, non-interactive, and repeatable. Avoid using System.out
for human verification; use assert
. Incremental code must pass unit tests. For database operations, prepare data using program insertion or import.
11 Security Regulations
Strictly bind SQL parameters to prevent SQL injection. Validate all user-requested parameters. Implement anti-scrubbing and anti-prohibited word filtering for user-generated content.
12 MySQL Database
12.1 Table Construction Regulations
Use is_xxx
for fields expressing yes or no. Table and field names should use lowercase letters or numbers. Avoid plural nouns in table names. Name tables with “business_name_table_role”. Keep character storage length appropriate for search speed.
12.2 Index Statute
Build unique indexes for fields with unique characteristics. Use covering indexes for query operations. Highest differentiation in combined indexes should be on the far left.
12.3 SQL Statement
Use count(*)
instead of count(column name)
or count(constant)
. Avoid using ${}
in ORM mapping to prevent SQL injection.
13 Engineering Structure
13.1 Application Layers
Simplify descriptions of application layers and focus on their main functionalities.
13.2 Second-party Library Dependency
Simplify the naming of version numbers and define a unified version variable when relying on a second-party library group.
13.3 Server
Recommend reducing the time_wait
timeout for highly concurrent servers. Use forward for internal redirection and an URL assembly tool class for external redirection.
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!