Line lengths discussed in eclipse forum and on reddit
Bruno Medeiros
brunodomedeiros+spam at com.gmail
Fri Sep 30 10:03:32 PDT 2011
On 11/09/2011 21:29, Don wrote:
>
> Interesting to me was the quote from Linus, saying that indentation
> depth should never exceed 3. If you accept that, then 80 characters
> seems perfectly reasonable.
Hum, while it may be true that Java code typically has more indentation
levels than say, C, I think that is not even close to being the major
contributing factor to line length. Class and method names are likely
more influential (in Java, and potentially in other languages as well).
As well as function parameters.
I give you this example I posted last time this issue was discussed:
""
private static final SimpleDateCachedFormatter
futuresDescriptionDateFormat = new SimpleDateCachedFormatter("MMMMM yyyy");
It's a real life Java line of code. It's 127 in length, so it is over
even my preferred maximum (120). Yet there are few tokens, the line is
"semantically" short, it does not do much. Because of that I do not feel
like wrapping or splitting it.
In D you could shave off the "SimpleDateCachedFormatter" with an "auto"
type inferrence declarator. It's still 107 chars in length. Maybe rename
the variable to "futuresDescriptionDF", since the "...DateFormat" in the
name does not add new info, you can see that is implied by the type?
Still 98 characters.
""
That's still 18 over the limit of 80, and that's in D code. (more or
less, 'final' would have to changed to const or immutable)
--
Bruno Medeiros - Software Engineer
More information about the Digitalmars-d
mailing list