Skip to content

CodingStyle

Henry Haiying Cai edited this page Feb 13, 2015 · 12 revisions
  • Author: Henry
  • Reviewer: Yinan

Overview

The code formatting standard in this project is based on the Oracle/Sun Code Convention and Google Java Style.

Callout

The coding style is consistent with most of the open source projects with the following callout:

  1. Naming Conventions

    • Class and instance variables begin with an underscore ("_"), e.g. _fooBar
    • Local variables are camel case beginning with a lowercase letter, e.g. fooBar
    • Constant variables are declared as static final and should be all uppercase ASCII letters delimited by underscore ("_"), e.g. FOO_BAR
  2. Import statement Do not use 'star' imports

  3. Indentation

  4. White space

  5. Comments

  6. Compound statements

Code Style Template File

  • Eclipse
    • Download the codetyle-eclipse.xml, Import the file through Preferences > Java > Code Style > Formatter
    • Download the prefs-eclipse.epf, Import the file File > Import > General > Preferences
  • IntelliJ
    • Download the codestyle-intellij.xml, Copy the file to ~/.IntelliJIdeal3/config/codestyles on Linux (or $HOME/Library/Preferences/IntelliJIdeal3/codestyles on Mac)
    • Restart the IDE
    • Go to File > Settings > Code Style > General > Scheme to select the new style
Clone this wiki locally