Fennec/NativeUI/CodingStyle: Difference between revisions

Jump to navigation Jump to search
(→‎Closing resources: fix finally block)
Line 29: Line 29:


* Places we differ from the Java coding style:
* Places we differ from the Java coding style:
** Start class variable names with m (e.g. mSomeClassVariable)
** Start class variable names with 'm' prefix (e.g. mSomeClassVariable) and static variables with 's' prefix (e.g. sSomeStaticVariable)
** Don't use wilcard imports.
** import statements:
*** Do not use wildcard imports like `import java.util.*;`
*** Organize imports by blocks separated by empty line: org.mozilla.*, com.*, net.*, org.*, android.*, then java.*
*** Within each import block, alphabetize import names with uppercase before lowercase (so `com.example.Foo` is before `com.example.bar`).
** 4-space indents
** 4-space indents
** spaces, not tabs
** spaces, not tabs
** Don't restrict yourself to 80-character lines. Java code tends to be long horizontally, so use appropriate judgement when wrapping. Avoid deep indents on wrapping. Note that aligning the wrapped part of a line with some previous part of the line (rather than just using a fixed indent) may require shifting the code every time the line changes, resulting in spurious whitespace changes.
** Don't restrict yourself to 80-character lines. Google's Android style guide suggests 100-character lines. Java code tends to be long horizontally, so use appropriate judgement when wrapping. Avoid deep indents on wrapping. Note that aligning the wrapped part of a line with some previous part of the line (rather than just using a fixed indent) may require shifting the code every time the line changes, resulting in spurious whitespace changes.
* The [http://source.android.com/source/code-style.html Android Coding Style] has some useful guidelines too.
* The [http://source.android.com/source/code-style.html Android Coding Style] has some useful guidelines too.


Confirmed users
3,339

edits

Navigation menu