-
Notifications
You must be signed in to change notification settings - Fork 751
CodingStyle
Andrew Hollenbach edited this page Oct 15, 2015
·
12 revisions
The code formatting standard in this project is based on the Oracle/Sun Code Convention and Google Java Style.
The coding style is consistent with most of the open source projects with the following callout:
-
Naming Conventions
- 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
- Variables are camel case beginning with a lowercase letter, e.g.
-
Import statement
- Do not use 'star' imports, e.g.
import java.io.*
; - Import order:
java
,org
,com
,gobblin
.
- Do not use 'star' imports, e.g.
-
Indentation
- Two spaces should be used as the unit of indentation;
- Tabs must expand to spaces and the tab width should be set to two;
- Line length: lines should not exceed 120 characters;
-
White space
- Blank lines should be provided to improve readability:
- Between the local variables in a method and its first statement
- Between methods
- Blank spaces should be used in the following circumstances:
- A keyword followed by a parenthesis should be separated by a space (e.g.
while (true) {
) - A binary operators except . should be separated from their operands by spaces (e.g.
a + b
);
- A keyword followed by a parenthesis should be separated by a space (e.g.
- Blank lines should be provided to improve readability:
-
Comments:
- Implementation comments: Block comments (
/* ... */
), end-of-line comments (//...
) can be used to illustrate a particular implementation; - Documentation comments (
/** ... */
) should be used to describe Java classes, interfaces, methods;
- Implementation comments: Block comments (
-
Compound statements are lists of statements enclosed in curly braces and should be formatted according to the following conventions:
- The enclosed statements should be indented one more level than the enclosing statement
- The opening brace should be on the same line as the enclosing statement (e.g. the 'if' clause)
- The closing brace should be on a line by itself indented to match the enclosing statement
- Braces are used around all statements, even single statements, when they are part of a control structure, such as if-else or for statements. This makes it easier to add statements without accidentally introducing bugs due to forgetting to add braces.
- 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
- Download the codestyle-intellij.xml, Copy the file to
- Home
- [Getting Started](Getting Started)
- Architecture
- User Guide
- Working with Job Configuration Files
- [Deployment](Gobblin Deployment)
- Gobblin on Yarn
- Compaction
- [State Management and Watermarks] (State-Management-and-Watermarks)
- Working with the ForkOperator
- [Configuration Glossary](Configuration Properties Glossary)
- [Partitioned Writers](Partitioned Writers)
- Monitoring
- Schedulers
- [Job Execution History Store](Job Execution History Store)
- Gobblin Build Options
- Troubleshooting
- [FAQs] (FAQs)
- Case Studies
- Gobblin Metrics
- [Quick Start](Gobblin Metrics)
- [Existing Reporters](Existing Reporters)
- [Metrics for Gobblin ETL](Metrics for Gobblin ETL)
- [Gobblin Metrics Architecture](Gobblin Metrics Architecture)
- [Implementing New Reporters](Implementing New Reporters)
- [Gobblin Metrics Performance](Gobblin Metrics Performance)
- Developer Guide
- [Customization: New Source](Customization for New Source)
- [Customization: Converter/Operator](Customization for Converter and Operator)
- Code Style Guide
- IDE setup
- Monitoring Design
- Project
- [Feature List](Feature List)
- Contributors/Team
- [Talks/Tech Blogs](Talks and Tech Blogs)
- News/Roadmap
- Posts
- Miscellaneous