2 ms·
I treat the parentheses the same way I treat the braces: void MyLongMethodName( SomeLongParamType param1, SomeOtherLongParamType param2,
by Rusky 9y ago
I treat the parentheses the same way I treat the braces:
void MyLongMethodName(
SomeLongParamType param1,
SomeOtherLongParamType param2,
YetAnotherLongParamType param3
) {
if (
longContrivedVariableName1 == longContrivedVariableName2 &&
longContrivedVariableName1 != longContrivedVariableName3
) {
// do stuff
}
}
I also make liberal use of temporary variables:
void MyLongMethodName(
SomeLongParamType param1,
SomeOtherLongParamType param2,
YetAnotherLongParamType param3
) {
auto condition1 = longContrivedVariableName1 == longContrivedVariableName2;
auto condition2 = longContrivedVariableName1 != longContrivedVariableName3;
if (condition1 && condition2) {
// do stuff
}
}
Vertical space is allocated to the actual parameters and conditions, and the extra syntax-only lines exist only to separate chunks. This works well with "paragraphs":
void MyLongMethodName(
SomeLongParamType param1,
SomeOtherLongParamType param2,
YetAnotherLongParamType param3
) {
auto condition1 = longContrivedVariableName1 == longContrivedVariableName2;
auto condition2 = longContrivedVariableName1 != longContrivedVariableName3;
if (condition1 && condition2) {
// do stuff
}
auto someData = buildSomeData();
doSomethingWith(someData);
while (someCondition) {
// loop
}
finishUp();
return someData;
}