• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Poll: Line Length Limits?

 
blacksmith
Posts: 1332
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay, I'm getting bored waiting for Ilja's promised next post in the "code vs. design" thread, so I'd like input on another process/people/practices issue: line lengths.

1. Do you prefer to have a line length limit or not?

2. If yes, what are your minimum, maximum, and preferred line length limits?

3. Why?

I've noticed that my practice is fairly out of synch with other people on my current project, and I'm wondering if I should be more flexible....
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay, I'm getting bored waiting for Ilja's promised next post in the "code vs. design" thread, so I'd like input on another process/people/practices issue: line lengths.
Ilja is quite busy right now. I'm pretty confident, he'll come back at some time. Don't worry


1. Do you prefer to have a line length limit or not?
2. If yes, what are your minimum, maximum, and preferred line length limits?
3. Why?

Best practices (Sun conventions, etc) advocate for 80-characters lines. Personally, I don't really have a preference as long as the code is readable. In some cases, you might need to write lines longer than 80 characters. Trying to make my code fit within 80 characters lines is not really my primary concern. Sometimes it is not even possible due to the length of the method and class names that you have to use (third-party libraries, etc).

Again, you can use code beautifiers for doing that for you, but none of these tools has really satisfied me as of today. For instance, when I use Checkstyle, I usually deactivate LineLength during development and then when I'm done I reactivate it just to have a feeling of how much longer my lines are

The bottom line is that fixing the length of the lines in your code is more a matter of personal preference or corporate policy. I think there are many things that much more important to check regarding the quality of your code than check if the lines are too long or not.
[ May 26, 2004: Message edited by: Valentin Crettaz ]
 
author
Posts: 799
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In writing, I've had to learn to make my lines as short as 60 characters. It's not very effective. Eighty characters is even a bit too short, given that today's high monitors and resolutions can present many more characters on a single line effectively. One hundred characters seems to work for many shops. One hundred twenty seems to be too many.

Yet every time I try to use the formatter to enforce a hard limit, even at 100 characters, there is always a line that ends up being formatted terribly. Having a stated guideline that developers can break (rarely and with good reason) seems to work better.

Instead of a hard number, my answer is "anything that doesn't force code readers to scroll horizontally." Once someone has to scroll to follow a method, you have temporary information loss, which makes code considerably harder to comprehend.

-j-
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We used to use 80 when my teams worked in Emacs. Now that we work in IntelliJ IDEA, we use 120. To a large extent, the right line length depends on the tools you use to work with the code.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Depends on the IDE and screen resolution. I run 1280 by whatever on a 21 inch monitor at work. I set the Eclipse formatter at 100 most of the time, set it up temporarily if it's splitting too much for me, set it back before I check code in.

I haven't used 80 since I moved off the mainframe. Actually used 72 there cause the editor reserved some columns for line numbers.
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For me, it depends on the tools, too. Basically, I don't like to have to scroll horizontally when working on code.

At work, we finally agreed on 100 characters a line.
 
The airline is called "Virgin"? Don't you want a plane to go all the way? This tiny ad will go all the way:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic