-
Notifications
You must be signed in to change notification settings - Fork 0
Code conventions
This page will collect all conventions for coding. That is supposed to establish a consistent style among all files.
In general, all variables should be written using camel case style:
thisIsAVariable
All member variables (except static final
ones, see later) should start with an underscore to be distinguishable from other variables:
private String _memberVariable;
If the a member variable stores a View (e.g. an EditText, TextView or ImageView), the variable should have a prefix that describes the type of the view in the following manner.
TextViews:
private TextView _tvName;
EditTexts:
private EditText _etName;
ImageViews:
private ImageView _ivProfilePicture;
Buttons:
private Button _btSubmit;
LinearLayouts:
private LinearLayout _llMainLayout;
This also applies to all custom subclasses of Views. They will get the same prefix as their well-known View base class.
The name of a static final
member variable has to be written in capital letters. To separate words there should be an underscore:
public static final int FRAGMENT_ID = 1;
Comments, either one-line or multiline comments, will always start with a capital letter:
// This is a test method
public void foo() {...}
/**
* This test method will print a test string.
*/
public void foo() {...}
This should also be the case for descriptions of method parameters or return values in the java doc:
/**
* This method will print a text.
*
* @param text The text that will be printed
*/
public void print(String text) {...}