Skip to content

Style Guideline

Jose Jimenez edited this page Dec 12, 2019 · 23 revisions

File Headers:

/**
 *
 * Jose Jimenez 
 * Brandon Cramer
 * Minh Pham
 * Tony Guan
 * Victor Chen
 *
 *                 University of California, San Diego
 *                      IEEE Micromouse Team 2020
 *
 * File Name:   <Name>
 * Description: <Short Description>
 */

Routine Headers:

Routine Headers will be in parallel with the Javadocs. Every header should have a short description of its role, a short description for all formal parameters, and what the function expects to return. An example is as follows:

  /**
   * Two pairs are equal if the content in the pair are equivalent order does 
   * not matter.
   * @param o object of comparison.
   * @return true if pairs have the same content.
   */
  @Override
  public boolean equals( Object o ) {
    ...
  }

Indentation:

Two space indentation. Four spaces to indicate a line continuation of the previous line.

Two space indentation:

Parenthesis clauses:

Max Width of File:

The recommended max of characters on a line is 80.

Example Routine:

/**
   * Combines two vertices in the disjoint set into one set via union by rank.
   * @param vertex_A Node in the maze.
   * @param vertex_B Node in the maze.
   * @return Nothing.
   */
  private void union( MazeNode vertex_A, MazeNode vertex_B ) {
    /* disjoint set representatives */
    MazeNode a_set = find( vertex_A );
    MazeNode b_set = find( vertex_B );

    if( a_set == b_set ) {
      /* no union needed - same set */
      return;
    }

    if( a_set.rank > b_set.rank ) {
      /* a rank is greater than rank of b */
      b_set.parent = a_set;
    }
    else {
      /* a_set is a smaller tree than b_set */
      a_set.parent = b_set;

      if( a_set.rank == b_set.rank ) {
        /* union of trees of equal height */
	b_set.rank = a_set.rank + 1;
      }
    }
  }

Clone this wiki locally