Official Code Format Guide
Official Code Format Guide
This guide is to show the proper format of code we prefer.
You can still submit patches with your own preferred formatting and we will convert them to our formatting, but if you are interested here is how it will be formatted:
The important points here are:
You can still submit patches with your own preferred formatting and we will convert them to our formatting, but if you are interested here is how it will be formatted:
Code: Select all
dlnaOrgOpFlags = "01";
if (mediaRenderer.isSeekByTime()) {
if (getPlayer() != null) {
if (getPlayer().isTimeSeekable()) {
/**
* This comment is on multiple lines so it gets the asterisks
* This comment is on multiple lines so it gets the asterisks
*/
if (mediaRenderer.isSeekByTimeExclusive()) {
dlnaOrgOpFlags = "10";
} else {
dlnaOrgOpFlags = "11";
}
if (mediaRenderer.isSeekByTimeExclusive()) {
dlnaOrgOpFlags = "10";
}
}
} else {
// This comment only uses one line
dlnaOrgOpFlags = "11";
}
}
- Each indentation is one tab, not spaces. This is done to allow each developer to customise their own indents (most code editors have an option like "tab size") instead of it being dictated to us by spaces. Note: Due to the way the forum displays code, the tabs have been converted to spaces, so just imagine they are tabs.
- Spaces between each separate part, for example on the fourth line there are 4 different spaces. This makes the code easier to read.
- Always use brackets for if statements, loops, etc. and put the else brackets on the same line, as in the 5th line from the bottom.
- Line-breaks between statements, as on the 15th line.
- No trailing spaces - there should be no spaces after any line.