I've come across a style issue that I'd like your input on: functions
returning extremely long return types, so that there's no way to put
return type and function name on the same line without breaking the 80
char limit. The style guide doesn't cover this situation, it just says
"The return type is always on the same line as the function name.",
which obviously isn't applicable here.
Question: do we prefer to indent the second line (i.e. the function
name), or don't we? I've seen both in existing code.
Examples:
Note 1: These aren't my code, so please don't tell me to just rename
something to make it shorter.
Note 2: Observe that I formatted the second example with indentation,
the first without, to demonstrate the difference.
const ConfigurationPolicyPrefKeeper::PolicyToPreferenceMapEntry*
ConfigurationPolicyPrefKeeper::FindPolicyInMap(...) {
// <method body>
}
ConfigurationPolicyProvider*
ConfigurationPolicyProviderKeeper::device_management_provider() const {
return device_management_provider_.get();
}
Personally, I tend to prefer indentation, since it indicates that it's
a wrapping of what should ideally be only one line; but you might also
argue that having no indentation is more readable (especially if
you've seen that style convention elsewhere before).
Is there any agreement, or at least a majority vote, on this?
Jakob
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
If style 1 is most prevalent, then I reckon stick with that one.
Note 1: These aren't my code, so please don't tell me to just rename
something to make it shorter.
Note 2: Observe that I formatted the second example with indentation,
the first without, to demonstrate the difference.
const ConfigurationPolicyPrefKeeper::PolicyToPreferenceMapEntry*
ConfigurationPolicyPrefKeeper::FindPolicyInMap(...) {
// <method body>
}
ConfigurationPolicyProvider*
ConfigurationPolicyProviderKeeper::device_management_provider() const {
return device_management_provider_.get();
}
On Thu, Dec 23, 2010 at 3:03 AM, Jakob Kummerow <jkum...@chromium.org> wrote:Note 1: These aren't my code, so please don't tell me to just rename
something to make it shorter.
Note 2: Observe that I formatted the second example with indentation,
the first without, to demonstrate the difference.
const ConfigurationPolicyPrefKeeper::PolicyToPreferenceMapEntry*
ConfigurationPolicyPrefKeeper::FindPolicyInMap(...) {
// <method body>
}
ConfigurationPolicyProvider*
ConfigurationPolicyProviderKeeper::device_management_provider() const {
return device_management_provider_.get();
}Use style 2. It is more consistent with how we deal with all other wrapping issues. IMO it is also slightly more readable.I enforce style 2 in all my code reviews and I change any instances of 1 to 2 in the codebase when I come across them.PK
--
Typedef in cc file could be used for the return type to shorten the line.
I guess there should be 4 spaces indent, not 2, right?