-
Notifications
You must be signed in to change notification settings - Fork 1
Create Naming and Coding Style Conventions #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| ### Variables | ||
| - Constants | ||
| - Preceded by `k` | ||
| - 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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
| } | ||
| ``` | ||
There was a problem hiding this comment.
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.