This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Agile and Other Processes and the fly likes Poll:  Line Length Limits? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » Agile and Other Processes
Bookmark "Poll:  Line Length Limits?" Watch "Poll:  Line Length Limits?" New topic
Author

Poll: Line Length Limits?

Warren Dew
blacksmith
Ranch Hand

Joined: Mar 04, 2004
Posts: 1332
    
    2
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....
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
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 ]

SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Jeff Langr
author
Ranch Hand

Joined: May 14, 2003
Posts: 762
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-


Books: Agile Java, Modern C++ Programming with TDD, Essential Java Style, Agile in a Flash. Contributor, Clean Code.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

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.


[Jess in Action][AskingGoodQuestions]
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
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.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
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 soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Poll: Line Length Limits?