Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions Software Documentation/Naming and Coding Style Conventions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
### Variables
- Constants
- Preceded by `k`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a line about constants being static final members. This is because the fields says "Fields are any variables found in the class body." A new user may get confused as to which naming convention to use.

- First word should be the name of the subsystem the constant is for
- Ex: `kDriveLeftRearTalonId`, `kLimelightFov`, `kControlLoopPeriod`
- Fields
- Preceded by `m`
- Fields are any variables found in the **class body**
- Ex: `mWristAngle`, `mGyroAngle`
- Parameters
- Preceded by `p`
- Ex:
```
public DriveStraight(Drive pDrive, double pDistanceToDrive) {
mDrive = pDrive;
mDistanceToDrive = pDistanceToDrive;
}
```

### Constructors
- If your class needs to use another classes' object, it should be passed into the constructor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of saying that you'll pass the specific classes, refer to them as dependencies. Also if the class implements an interface, the interface should be passed in to decouple from specific implementations.

- Settings that are essential to your code's functionality (like the number of degrees to turn for `GyroTurn`) can also be passed in

### Setting Properties
- If you need to override a default setting for a class, use the flow model

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by the flow model? I can infer from what it's doing, but I'm not sure this is covered for new developers. Focus on the pattern itself (flow pattern is when the setter method returns this.)

- Ex: To override the default power sent to the drivebase in the `DriveStraight` command:
```
public DriveStraight setPower(double pPower) {
mPower = pPower;
return this;
}
```
- This allows us to create a `DriveStraight` object like so:
```
ICommand = new DriveStraight(mDrive, 10.0 /*The distance to drive*/).setPower(0.5);
```

### Enumerations
- Enumeration classes are in

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommend adding a line about how to name the class itself. This only covers the enumerated values.

- Enumerations are in all caps, `LIKE_THIS`
- The rationale behind this naming scheme is that Codexes (which rely on enums) will eventually be sent from the robot and
deserialized into a database - and database column names are typically in all caps.
- Ex: States of a manipulator:
```
public enum EManipulatorState {
RESET, GRABBING, PLACING;
}
```