Page 1 of 1

Do you limit the length of code lines?

Posted: Mon Jun 09, 2008 6:49 am
by johnhpus
Looking through Visual Assist's options I found that it can draw a horizontal line at a given column, by default column 75, to suggest when you should move to a new line.

I've never really worried about the length of the lines of my code, other than going to a newline when I approach the edge of my screen. At both studios I have worked at, we all used the same monitors, and maybe that's why it never came up. I don't remember it being mentioned in the coding standards.

I would feel really cramped at 75 characters per line. Does anyone actually follow such guidelines?

Posted: Mon Jun 09, 2008 7:42 am
by steven
I try to limit to 75 or 80 characters for two reasons:

- With two VC open simultaneously side-by-side each taking half my wide-screen with 80 characters I don't need to scroll horizontally :)
- When printing code I like to do it with double columns in landscape format with Ultraedit. This permits the code formatting to stay nice (no ugly line breaks).

Posted: Mon Jun 09, 2008 7:52 am
by xavier
I never did until my current position, when one of the engineers on the team asked me if I did that. At the time I said no, I've never heard of that, but then it dawned on me that this comment line in code (such as Ogre)

Code: Select all

//----------------------------------------------------------------------------
was more than just decoration or function separator -- it served as a marker for line length. Since then I've been using it consistently (although not always limiting to the 78-characters of that line). ;)

Posted: Mon Jun 09, 2008 9:31 am
by Kojack
One of the places I worked at had a line length limit in the coding standard doc. Every file was printed out for multiple peer reviews, so we had a strict 78 character limit to fit on an a4 page without wraparound causing confusion.
The coding standard also specified where whitespace could be used, capitalisation, function names, etc.
It was annoying at first, but we had virtually zero integration issues when code from multiple programmers came together.

After that I still tend to follow a line limit, but I don't print code so I usually work to whatever fits in VC. Most of my coding is done in a full width source window on a 1280x1024 screen (the other panels like output, solution browser and stuff are on the second monitor), so I can get 153 characters per line without horizontal scrolling. But I generally don't go above 130.

Posted: Mon Jun 09, 2008 12:41 pm
by SunSailor
On my side, it really depends. On our linux components, I'm working with the vi and as it doesn't handle wraps very nice (only line wrapping, no scrolling), I tend to keep the code within the screen limits where possible. Rather short function names used in our linux components (They are command line only) are benefiting this. On the other hand, under windows the length of a lot of functions, especially from the windows API, are resulting in the fact, that a line can reach easily 100 and more characters per line - especially, as there sometimes to often isn't any suitable solution to wrap the code AND keep it readable.

Posted: Mon Jun 09, 2008 12:49 pm
by Klaim
I do it naturally only because reading long vertical lines is verry unconfortable. Simply look at newspapers and blogs, that's why the text nearly every time is horizontally limited.

Posted: Mon Jun 09, 2008 6:17 pm
by johnhpus
Thanks for the perspectives.

Reddit must be reading my mind, as there is an article on this topic linked from there today: http://richarddingwall.name/2008/05/31/ ... -relevant/

Posted: Mon Jun 09, 2008 10:32 pm
by nullsquared

Code: Select all

reallyBigObject.reallyBigFunction(
    someOtherReallyBigObject.doThisAndThatAndThoseToo(
        blah, foo, bar, foobar, barfoo, etc, profit),
    etcStuffThatNeedsToBe,
    passedtoTheReallyBigObject);
I hate horizontally scrolling, since that usually means I have to get choppy scrolling with the keys, or actually have to move my hand over to my mouse :roll:

Besides, indenting really helps with reading which parameters go where, sort of how block indentation works.

Posted: Tue Jun 10, 2008 2:11 am
by Game_Ender
I use a 80/79 character limit. Its because I hate horizontal scrolling and like the ability to have multiple code windows up one monitor at once. I have noticed many windows programmers are lazy with there line widths. I frankly look at as sloppiness ;), but I shouldn't be one to talk because I can be less consistent with other formatting issues myself.