tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremy Boynes <jboy...@apache.org>
Subject Re: Code style rules: Line length
Date Fri, 09 Aug 2013 00:44:26 GMT
On Aug 8, 2013, at 10:50 AM, Mark Thomas <markt@apache.org> wrote:

> Currently, Tomcat has an 'guide' of a maximum of 80 characters for line
> length. It has been a while since we reviewed this and as we are looking
> at style rules...
> 
> As a starting point what do folks think of the following options:
> 
> Line length:
> 80 - the current
> 100 -
> 120 -

My personal preference is to soft wrap around 120 and hard limit to something around 132 or
150.
The guideline I use for wrapping is "nothing beyond 120 that is critical to human understanding"
which seems to work for the type of constructs that lead to long lines (method signatures,
variable initializations) but which wraps things like invocations.

> Strictness
> Informal - the current
> Enforce  - Use checkstyle to enforce whatever limit is chosen

I think humans, who are the ones who care what the code looks like, make better judges than
the simplistic rules built into formatters or verifiers.

> Pros for longer lines:
> - code easier to read

I agree with this given wider monitors in landscape mode. I have found myself preferring longer
lines over time due to additional decoration in the code (e.g. generic type signatures).
Too short and the wrapping interrupts the flow, too long and horizontal eye movement means
you lose context.

> 
> Cons
> - diffs may wrap in mail clients
> - harder to work with code in a pure text interface (particularly if
> that interface is limited in width to 80 chars)
> 
> 
> Comment
> - With increasing screen resolution I expect IDEs to manage widths upto
> 120 or possibly even more

I think this is true for the monitors developers often use when activity working on the code
- a 1920 or 2560 horizontal resolution can be common (not counting "retina" type displays)
and that can handle side-by-side diffs at 120 or more characters. However, I also use lower
resolution screens such as a 1280 wide laptop but that can still display a single column at
120 wide (allowing for chrome).

> - Few (any?) folks will ever need to work in a pure text UI where the
> line length is limited
> - My only concern is readability of diffs

Specifically in email, which does depend on people's mail clients. Mailed diffs though are
not side-by-side so the main issue is whether wrapping makes it less readable.

...
If we do change, I think it should only apply to new code and not impact existing code - no
reformat for reformat's sake.

Cheers
Jeremy


Mime
View raw message