On Oct 30, 2008, at 1:34 PM, Dain Sundstrom wrote:

On Oct 30, 2008, at 1:09 PM, Alex Grönholm wrote:

Dain Sundstrom kirjoitti:
On Oct 29, 2008, at 10:44 AM, Alex Grönholm wrote:

Formatter:
- max line width is 100 characters

I prefer 120, but as long as it is only suggestion it isn't a big deal for me.

I don't how you do your editing, but in my case, 120 characters is already so wide that I frequently have to shift my eyes horizontally to read the whole line, and it doesn't fit on my editor window (with 1600x1200 screen size). I expect many other developers to have even smaller screens, so I figured 100 characters would be a reasonable suggestion.
But like you said, it's just a recommendation.

I find that long lines are typically exception messages or methods with long args. In the vast majority of cases, the details are not important.


Just whipped up a little line checker thingy to see what we're doing now.

80   = 91.19165439539742
100  = 5.488681894455669
120  = 2.004212184514229
140  = 0.805195027567549
141+ = 0.5102564980651347

Seems we trail off after 120 lines. I'd be fine with a soft recommendation of 120 lines for non "signatures" (i.e. method signatures, constructor signatures). But please no code with strange breaks like these:

Example #1
this.serviceConstructor = FastClass.create(this.enhancedServiceClass).getConstructor(
            SERVICE_CONSTRUCTOR_TYPES);

Example #2
throw (NamingException) new NamingException("Could not load service interface class " + serviceInterfaceClassName).
                        initCause(e);

In both situations, I'd probably leave the line long. But if you really feel compelled to get under 120, something like this would be better:

Example #1
String message = "Could not load service interface class " + serviceInterfaceClassName; throw (NamingException) new NamingException(message).initCause(e);

Example #2
FastClass fastClass = FastClass.create(this.enhancedServiceClass); this.serviceConstructor = fastClass.getConstructor(SERVICE_CONSTRUCTOR_TYPES);


Try to break lines in ways that end in either a '{' or a ';'. Try not to break matching '(' and ')' unless it an inner-class. Please don't dig out the '+' to break lines unless you're spanning more than just one or two lines.


-David


Reply via email to