|
http://www.jindent.com |
Previous: Declarations
|
Next: Operators
|
| Enable line wrapping to fit source code to maximal line length |

| Maximal line length |

|
int longName1 = (longName2 - longName3 - longName4) / (longName5 + longName6 + longName7); |
|
int longName1 = (longName2 - longName3 - longName4) | / (longName5 + longName6 + longName7); | |
/.
Additionally the wrapped line will be aligned correctly to its corresponding operand.
| Line wrapping policy |

|
callALongMethodName(callMethodA(anArg, anotherArg), | callMethodB(anArg, anotherArg), | callMethodC(anArg, anotherArg), | callMethodD(anArg, anotherArg), | callMethodE(anArg, anotherArg), | callMethodF(anArg, anotherArg)); | |
|
callALongMethodName(callMethodA(anArg, anotherArg), callMethodB(anArg, anotherArg), callMethodC(anArg, anotherArg), callMethodD(anArg, anotherArg), callMethodE(anArg, anotherArg), callMethodF(anArg, anotherArg)) | |
| Wrap lines even if only comments exceed maximal line length |

|
public void method() | { | value = function(parameter1, parameter2); // exceeding comment } | |
|
public void method() | { | value = function(parameter1, | parameter2); // exceeding comment | } | |
| Alternative indentation |

|
See also: | Maximal gap size of indentations , Avoid confusing indentations |
| Maximal gap size of indentations |

|
public class MyClass { | | void iKnowThisLooksStupidButItIsOnlyAnExample(Parameter one, | Parameter two, | Parameter three) { | firstLineOfCode(); | ... | } | } | |
|
public class MyClass { | | void iKnowThisLooksStupidButItIsOnlyAnExample(Parameter one, | |---- gap size relative to block indent -----|Parameter two, Parameter three) { | firstLineOfCode(); | ... | } | } | |
|
public class MyClass { | | void iKnowThisLooksStupidButItIsOnlyAnExample(Parameter one, | |-------------- absolute gap size ----------------|Parameter two, Parameter three) { | firstLineOfCode(); | ... | } | } | |
|
public class MyClass { | | void iKnowThisLooksStupidButItIsOnlyAnExample(Parameter one, | |------ relative gap size: 46 spaces --------|Parameter two, Parameter three) { | firstLineOfCode(); | ... | } | } | |
|
public class MyClass { | | void iKnowThisLooksStupidButItIsOnlyAnExample(Parameter one, | |------|Parameter two, | Parameter three) { | firstLineOfCode(); | ... | } | } | |
infinite to leave all kind of gaps untouched.
|
See also: | Alternative indentation , Maximal gap size of indentations for multiple variable and field declarations |
| Avoid confusing indentations |

||!(condition5 && condition6)
is correctly aligned to (condition1 && condition2):
|
if ((condition1 && condition2) || (condition3 && condition4) | ||!(condition5 && condition6)) { | callMethodA(); // line is easy to miss | } | |
callMethodA() is easy to miss.
It seems it belongs to the conditions of the superior if statement. Such an indetation is
considered as 'confusing indentation'.
|
if ((condition1 && condition2) || (condition3 && condition4) | |------|||!(condition5 && condition6)) { | callMethodA(); // line is easy to miss | } | |
callMethodA(); is now separated from the if conditions and well-defined.
|
See also: | Alternative indentation |