Skip to content
samcrow edited this page Jun 13, 2012 · 2 revisions

So far our code style has been dictated by standard Java practices and the default automatic code styling that NetBeans applies. This document makes all the guidelines that we've been following available in one place. Keep in mind that these are only suggestions. If breaking these rules would make something measurably easier or better, go for it.

Project types

Projects for competition code should use the CommandBasedRobot structure. This framework is very helpful for the complex, multi-part code that we use in competition.

Other projects can use any other structure.

Project structure

Every project should have a base package of org.team751. Utility classes that are used in multiple locations and/or not directly related to the core code should go in the package org.team751.util.

Classes that are used to interface with sensors should go in the package org.team751.sensors.

For command-based robot projects, the org.team751.commands package should have the following structure:

  • org.team751.commands: The autonomous command (if any), CommandBase, any other commands that don't focus specifically on one or two subsystems
  • Each subsystem should have its own subpackage of org.team751.commands. The name of this subpackage should be the name of the subsystem in lowercase. For example, the subsystem Drivetrain should have a subpackage at org.team751.commands.drivetrain.
  • Each of those subsystem subpackages should contain the commands that are used to control that subsystem.

Naming classes

Each class should have a CamelCase name with the first letter capitalized. All letters of acronyms should be capitalized (example: PIDShooterWheels is correct, PidShooterWheels is not).

Naming constants (final class members)

Every class member that is declared as final (i.e. every constant field) should have a CamelCase name starting with a lowercase k. All letters of acronyms should be capitalized. This saves time and effort associated with reaching for the _ key and holding down the shift key to type a whole constant name in capital letters.

Right:

public static final double kUpperAngleLimit = 4.622;

Wrong:

public static final double UPPER_ANGLE_LIMIT = 4.622;

Clone this wiki locally