Coding Guidelines
Coding Guidelines
public myMethod() {
Log.e(TAG, "My error message")}}}
1.11. Line length limit
Code lines should not exceed 100 characters. If the line is longer than this limit
there are usually two options to reduce its length:
Extract a local variable or method (preferable).
Apply line-wrapping to divide a single line into multiple ones.
1.11.1. Line-wrapping strategies
There isn't an exact formula that explains how to line-wrap and quite often
different solutions are valid. However, there are a few rules that can be applied
to common cases. Break at operators when the line is broken at an operator, the
break comes before the operator. For example:
int longName = anotherVeryLongVariable + anEvenLongerOne - thisRidiculousLongOne
+ theFinalOne;
1.11.2. Assignment Operator Exception
An exception to the break at operators rule is the assignment operator =, where the
line break should happen after the operator.
int longName =
anotherVeryLongVariable + anEvenLongerOne - thisRidiculousLongOne +
theFinalOne;
1.11.3. Method chain case
When multiple methods are chained in the same line - for example when using
Builders - every call to a method should go in its own line, breaking the line
before the.
Picasso.with(context).load("http://ribot.co.uk/images/
sexyjoe.jpg").into(imageView);
Picasso.with(context)
.load("http://ribot.co.uk/images/sexyjoe.jpg")
.into(imageView);