Code Standards, Sprint Tasks, and Plans by FZU Flying Club


This assignment belongs to which courseEE308FZ Software Engineering https://bbs.youkuaiyun.com/forums/ssynkqtd-04
Where this assignment is requiredhttps://bbs.youkuaiyun.com/topics/617606376
Team nameFZU Flying Club
The goal of this assignmentHelp students understand Alpha Sprint and promote course project progress
Other referencesNone

1 Code Standard

1.1 Code requirements

(I) Naming style
Use UpperCamelCase style for class name, and must follow the hump form; method name, parameter name, member variable, local variable all use lowerCamelCase style, and must follow the hump form; name constants in all upper case, and use underscore to separate words, and try to express the semantics completely and clearly, and don’t mind the name is too long; the middle bracket is a part of the type of array, and array is defined as follows: String[] args; if module, interface, class, method use design pattern, the naming reflects the specific pattern. defined as follows: String[] args; if the module, interface, class, method uses a design pattern, reflect the specific pattern in the naming; subsequent requirements will continue to increase.

(II) Constant definitions
Do not allow any magic values (i.e., undefined constants) to appear directly in the code; do not use one constant class to maintain all constants; group constants according to their function and maintain them separately; there are five levels of reuse of constants: cross-application shared constants, intra-application shared constants, intra-subproject shared constants, intra-package shared constants, and intra-class shared constants; if the value of a variable varies only within a range with an extended attribute other than name If the value of the variable varies only within a range and has extended attributes other than the name, it is defined as an enumerated class.

(III) Code Format
Conventions for the use of curly brackets. If there is empty space inside the curly brackets, write {} succinctly without line breaks; there is no space between the left parenthesis and the character; similarly, there is no space between the right parenthesis and the character; there must be a space between reserved words such as if/for/while/switch/do and the parentheses; there must be a space between the left and right side of any binomial or trinomial operator; there is a space between the double slash of the comment and the content of the comment, and only one between the double slash and the content of the comment. There is only one space between the double slash of a comment and the content of the comment; method parameters must be defined and passed in with a space after the comma for multiple parameters.

(IV) OOP protocol
Avoid accessing such static variables or static methods through a class object reference, unnecessarily increasing the compiler’s parsing costs, directly with the class name to access can be; all override methods, must add @Override annotation; the same parameter types, the same business meaning, you can use Java’s variable parameters, avoid using Object; all the same type of wrapper class object value comparison between all using equals method comparison; constructor methods are prohibited to add any business logic, if there is initialisation logic, please put it in the init method. Comparison between the values of all objects of the same type of wrapper class, all use the equals method to compare; constructor method is prohibited to add any business logic, if there is initialisation logic, please put it in the init method.

(V) Collection Handling
Regarding the handling of hashCode and equals, the following rules are followed: 1) As long as equals is rewritten, hashCode must be rewritten. 2) Because Set stores non-repeating objects, and judgement is made based on hashCode and equals, the objects stored in Set must rewrite these two methods. 3) If a custom object is used as the key of Map, then hashCode and equals must be overridden. to use the method of converting a set to an array, you must use the toArray(T[] array) of the set, and pass in an array of exactly the same type, and the size of the array is list.size(). When you use the tool class Arrays.asList() to convert an array to a collection, you cannot use it to modify the collection-related methods, and its add/remove/clear methods will throw the UnsupportedOperationException exception.

(VI) Concurrency Handling
Getting a singleton object needs to be thread-safe, and its methods need to be thread-safe as well. When creating threads or thread pools, please specify meaningful thread names for easy backtracking in case of errors. Thread resources must be provided through the thread pool, and it is not allowed to create threads explicitly in the application itself. At high concurrency, synchronous calls should take into account the performance loss of locks. If you can use lockless data structures, don’t use locks; if you can lock blocks, don’t lock entire method bodies; if you can use object locks, don’t use class locks. At high concurrency, synchronous calls should consider the performance loss of locks. If you can use lockless data structures, don’t use locks; if you can lock blocks, don’t lock the entire method body; if you can use object locks, don’t use class locks. When you modify the same record concurrently, you need to add locks to avoid losing updates. Either add locks at the application level, add locks in the cache, or use optimistic locks at the database level and use version as the basis for updates.

(VII) Control statements
Within a switch block, each case is either terminated by break/return, etc., or annotated to indicate which case the program will continue to execute to; within a switch block, a default statement must be included and placed at the end, even if it contains no code at all. You must use curly braces in if/else/for/while/do statements. Even if there is only one line of code, avoid single line coding: if (condition) statements; do not execute complex statements in conditional judgements except for common methods (e.g., getXxx/isXxx), etc., and assign the result of complex logical judgements to a meaningful Boolean variable name to improve readability.

(VIII) Annotation
Classes, class attributes and class methods must be annotated using the Javadoc specification, using the /content/ format, and must not use the // xxx method. All abstract methods (including methods in interfaces) must be annotated with Javadoc. In addition to return values, parameters, and exceptions, the method must also indicate what it does and what it achieves. Instead of “half-assed” English annotations, it is better to use Chinese annotations to make the problem clear. Proper nouns and keywords should be kept in the original English.

(IX) Other
When using regular expressions, make good use of its pre-compile function, you can effectively speed up the regular matching speed.

1.2 Exception Handling

The Java library defines a class of RuntimeException that can be circumvented by pre-checking and should not be handled by catching, e.g. IndexOutOfBoundsException, NullPointerException, etc. It is irresponsible to try-catch large pieces of code. It’s irresponsible to try-catch large pieces of code, and when doing so, distinguish between stable code and unstable code, which is code that can’t go wrong anyway. Stable code is code that will not go wrong no matter what. For non-stable code, try to differentiate between the types of exceptions in the catch, and then handle the exceptions accordingly. If you have a try block in transaction code, and you need to roll back the transaction after a catch, be sure to roll back the transaction manually. Caught exceptions and thrown exceptions must be exact matches, or the caught exception must be the parent of the thrown exception.

1.3 Unit Testing

Good unit tests must follow the AIR principles. Unit tests should be fully automated and non-interactive. Test frameworks are usually executed at regular intervals, and the execution must be fully automated to be meaningful. A test whose output needs to be checked manually is not a good unit test. Unit tests are not allowed to use System.out for human verification, they must be verified using assert. Unit tests are repeatable and cannot be affected by the external environment. The incremental code of the core business, core application and core module must pass the unit test. For database-related query, update, delete and other operations, you can not assume that the data in the database exists, or directly manipulate the database to insert data into it, please use the program to insert or import data to prepare the data.

1.4 Security Regulations

For querying, updating, deleting, etc., you cannot assume that the data in the database exists, or directly operate the database to insert data into it, but please use the method of program insertion or import to prepare the data. SQL parameters entered by the user should be strictly parameter-bound or METADATA field-value-qualified, preventing SQL injection and forbidding string-spliced SQL access to the database. Any parameter passed in by the user request must be validated. Prohibit outputting user data to HTML pages without security filters or proper escaping. User-generated content such as posting, commenting, instant messaging and other scenarios must implement anti-scrubbing and anti-prohibited word filtering of text content.

1.5 MySQL Database

(I) Table Construction Regulations
Fields that express the concept of yes or no must be named with is_xxx and the data type is unsigned tinyint (1 for yes, 0 for no). Table names and field names must use lowercase letters or numbers, and it is forbidden to have numbers at the beginning and only numbers in the middle of two underscores. Changes to database field names can be costly, and field names need to be considered carefully because they cannot be pre-released. Do not use plural nouns in table names. Tables should preferably be named with “business_name_table_role”. The library name and the application name should be the same as far as possible. Appropriate character storage length not only saves database table space and index storage, but more importantly, improves the search speed.

(II) Index Statute
Fields with unique characteristics in business, even if it is a combination of multiple fields, must be built into a unique index. Use the covering index to perform query operations and avoid going back to the table. When building a combined index, the highest differentiation is on the far left.

(III) SQL statement
Don’t use count(column name) or count(constant) instead of count(), count() is the standard syntax of counting rows defined by SQL92, which has nothing to do with the database, and has nothing to do with NULL and non-NULL. count(distinct col) calculates the number of unduplicated rows of the column except NULL, note that count(distinct col1, col2) is the same as count(distinct col1, col2), if count(distinct col1, col2) is used, it is not necessary to count the number of rows in the column. distinct col1, col2) returns 0 if one of the columns is NULL, even if the other column has a different value. foreign keys and cascading are not allowed; all foreign key concepts must be resolved at the application level. When revising data, when deleting and modifying records, select first to avoid erroneous deletion and confirm that there is no error before executing the update statement.

(IV) ORM Mapping
In the table query, do not use * as the query field list, which fields are needed must be clearly written. Don’t use resultClass as return parameter, even if all the class attribute names correspond to the database fields one by one, you need to define them; in turn, each table must have a corresponding one. sql.xml configuration parameter use: #{}, #param# Don’t use ${} This way is prone to SQL injection. HashMap and Hashtable are not allowed to be used directly as the output of the query result set.

1.6 Engineering Structure

(I) Application Layers

Open interface layer: Can directly encapsulate service method and expose it as RPC interface; encapsulate it as http interface through the Web; and carry out gateway security control, traffic control, and so on.

Terminal display layer: the layer where templates of each end are rendered and displayed. Currently, it is mainly velocity rendering, JS rendering, JSP rendering, mobile display and so on.

Web Layer: Mainly forwarding access control, checking all kinds of basic parameters, or simple processing of non-reusable business.

Service Layer: Relatively specific business logic service layer.

Manager layer: general business processing layer, which has the following characteristics:

(1) The layer encapsulating the third-party platform, pre-processing the return results and transforming the abnormal information;
(2) Sinking of the general capabilities of the Service layer, such as caching scheme and middleware general processing;
(3) Interaction with the DAO layer, reuse of multiple DAO combinations.

DAO layer: data access layer, data interaction with underlying MySQL, Oracle, Hbase, etc.

External interfaces or third-party platforms: including RPC open interfaces of other departments, basic platforms, and HTTP interfaces of other companies.

(II) Second-party library dependency

Naming of the version number of the second-party library: main version number. Secondary version number. Revision number

(1) Major version number: product direction change, or large-scale API incompatibility, or architectural incompatibility upgrade.
(2) Sub-version number: Maintain relative compatibility, add major functional features, and modify API incompatibility with minimal impact.
(3) Revision number: Maintain full compatibility, fix bugs, add minor features, etc. When relying on a two-party library group, you must define a unified version variable to avoid inconsistent version numbers.

(III) Server
It is recommended to reduce the time_wait timeout of TCP protocol for highly concurrent servers. Use forward for internal redirection of the server; use URL assembly tool class to generate the external redirection address, otherwise, it will bring the problem of inconsistent URL maintenance and potential security risks.

2 Sprint Tasks

2.1 Plan1: Website creation

Development tools and technologies: Choose appropriate development tools according to team members’ skills and project needs, such as using modern front-end frameworks (e.g. React, Vue.js) and back-end languages (e.g. Node.js, Python, etc.).
Build the basic framework: Build the basic framework and structure of the website, including the basic layout of the website, navigation bar, footer and so on.

2.2 Plan2: Page theme construction

Design website theme: design the overall style and theme of the website according to the positioning of the project. Consider implementing daytime and nighttime modes to ensure a beautiful and easy-to-use interface.
Develop page styles: create the CSS styles required by the website to ensure that the layout and style of the page elements meet the design requirements.

2.3 Plan3: Content section division

Establishing different information modules: According to the requirements, create pages for experience sharing of studying abroad, in-country advancement board, comment area of the information board, comment area module, and so on.
Develop content management system: Create administrator page to allow administrators to manage and edit the content.

2.4 Plan4: Build comment section and online chat function

Develop commenting functionality: build comment sections for each information module and ensure that users can easily post comments and interact with each other.
Implement online chat function: Consider using technologies such as WebSocket to provide users with the ability to chat online.

2.5 Plan5: Markdown online editor

Integrate Markdown editor: Provide users with a convenient Markdown editor so that they can easily compose formatted content.
Implement data storage: Ensure that the editor’s content can be securely saved to a database.

3 Specific division of labour and plan

3.1 Day1-2: Finish Plan1 website building

Website build:
Zhang Qin
Chen Zhengang
Chen Yuheng

Testers:
Zhang Jiayang
Chen Jinghua

Blog written by:
Zhang Qin
Zhao Pan

3.2 Day3-4: Complete Plan2 page theme construction

Page theme construction:
Chen Zhengang
Yin Xiangbin
Liu Yiqi

Tester:
Zhang Qin
Zhang Jiayang
Chen Jinghua

Blog written by:
Zhang Qin
Yi Li

3.3 Day5-6: Complete Plan3 content column division

Content column division:
Chen Zhengang
Zhang Qin

Tester:
Yin Xiangbin
LiuYiqi

Blog written by:
Zhang Qin
Hu Jiachen

3.4 Day7-8: Complete Plan4 to build comment section and online chat function

Build the comment section and online chat function:
Zhang Jiayang
Chen Jinghua
Chen Zhengang
Chen Yuheng

Testers:
Yin Xiangbin
Liu Yiqi
Zhang Qin
Peng Houming

Blog written by:
Zhang Qin
Chen Zhengang

3.5 Day9-10: Finish Plan5 markdown online editor

Make Markdown online editor:
Chen Zhengang
Zhang Jiayang
Chen Yuheng

Testers:
Zhang Qin
Liu Yiqi
Yin Xiangbin

Blog written by:
Zhang Qin
Chen Zhengang
Peng Houming

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值