English | 中文简体
This programming guidebook is used for development in Next-Innovation(NI).
The guidebook is designed by the rules below:
- Do not ignore readability in order to blindly pursue the speed of code.
- On the premise of speed , readability is everything.
- On the premise of readability, shorter is better.
Every developer should follow the rules while programming or pushing the code.
This guidebook contains:
- Suggested VS-Code extensions.
- The code style.
- NI Programming Guide
- WPILIB
- Java Extension Pack
- Bracket Pair Colorizer 2
- google-java-format
- Todo Tree
- GitLens — Git supercharged
- Better-Comments
Note: To have a better support for 3rd lib, only file names is necessary to be formatted.
-
Structure:
- Example:
- No line-wrapped.
- The package statement should be divided from import statements by a blank line.
-
Static import or otherwise are not used.
-
No line-wrapped.
-
Imports from the same package should be put together.
-
Imports from different packages should be separated by a blank line.
-
Example:
Bad:
Good:
-
The order of members does not need to follow specific strict rules. What is important is that each class uses some logical order.
-
Overloads should never be split.
-
Members of the same type should be put in the same block, and different blocks should be separated by annotation of a specific style.
-
Example:
Bad:
Good:
- NI's format style is following the Google's format style of Java. You can click here for more information: Google Java Style Guide - Formatting.
- In fact, all formatting can be done by the extension -- google-java-format.
Identifiers use ASCII letters and digits only. On the premise of name readability, shorter is better.
-
UpperCamelCase
-
The name of a concrete class cannot have a prefix or suffix.
-
The name of an abstract class should have a prefix of "base".
-
The name of the interface should have a prefix of "I".
-
Example:
-
lowerCamelCase
-
The name of the same type of method should start with the same word. For example, the subsystem of the chassis may have multiple setters to control the motors in different modes (Open-Loop, Velocity, Position), so their names should start with "set".
-
Example:
-
UPPER_AND_UNDER_SCORE_CASE
-
Example:
-
lowerCamelCase
-
Whether the variable is public or private, do not add any prefix or suffix to it.
-
Example:
- Don't add unnecessary getter or setter.
- Always use
@Override
. - Always use
synchronized
for all methods about IO. - Do not ignore catching exceptions.
- Always specify the order of instantiation.
❤️ This project exists thanks to all the people who contribute. ❤️