Skip to content

The programming guidebook in NI, Including code style and development process

Notifications You must be signed in to change notification settings

frcnextinnovation/NI-Programming-Guide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 

Repository files navigation

English | 中文简体

NI Programming Guide

Next-Innovation standard-readme compliant Lang

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:

  1. Suggested VS-Code extensions.
  2. The code style.

NEXT_Innovation

Table of Contents

1. VS-Code-Extensions

2. Code-Style

Note: To have a better support for 3rd lib, only file names is necessary to be formatted.

2.1 Source-File

  • Structure:

    1. License or copyright information(if present).
    2. Package statement.
    3. Import statements.
    4. Class statements.

2.1.1 License or copyright information

  • Example:

2.1.2 Package statement

  • No line-wrapped.
  • The package statement should be divided from import statements by a blank line.

2.1.3 Import statements

  • 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:

    Import-Bad

    Good:

    Import-Good

2.1.4 Class

  • 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:

    Source-File-Class-Format

    Good:

    Source-File-Class-Format-Good

2.2 Formatting

2.3 Naming

2.3.1 Rules common to all identifiers

Identifiers use ASCII letters and digits only. On the premise of name readability, shorter is better.

2.3.2 Rules by identifier type

2.3.2.1 Package names
  • lowercase

  • Example:

    Package-names
2.3.2.2 Class & Interface names
  • 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:

    Class-Names
2.3.2.3 Method names
  • 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:

    Method-Name
    2.3.2.4 Constant names
  • UPPER_AND_UNDER_SCORE_CASE

  • Example:

    Constant-Name
2.3.2.5 Non-constant field names
  • lowerCamelCase

  • Whether the variable is public or private, do not add any prefix or suffix to it.

  • Example:

    Non-Constant-Variables-Name
2.3.2.6 Local variable names
  • lower_and_under_score_case

  • Example:

    Parameter-Name

2.4 Programming-Practices

  • 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.

Maintainers

@Rocky_ @ljy1992

Contributors

❤️ This project exists thanks to all the people who contribute. ❤️

@ljy1992 @Rocky_ @yukikisss

contributors

About

The programming guidebook in NI, Including code style and development process

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published