Do you limit the length of code lines?

A place for Ogre users to discuss non-Ogre subjects with friends from the community.
Post Reply
User avatar
johnhpus
Platinum Sponsor
Platinum Sponsor
Posts: 1186
Joined: Sat Apr 17, 2004 2:49 am
x 3

Do you limit the length of code lines?

Post 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?
User avatar
steven
Gnoll
Posts: 657
Joined: Mon Feb 28, 2005 1:53 pm
Location: Australia - Canberra (ex - Switzerland - Geneva)
Contact:

Post 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).
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Post 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). ;)
Do you need help? What have you tried?

Image

Angels can fly because they take themselves lightly.
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 538

Post 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.
User avatar
SunSailor
Gnoll
Posts: 699
Joined: Sun Jan 02, 2005 5:45 pm
Location: Velbert, Germany
x 2
Contact:

Post 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.
User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
x 56
Contact:

Post 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.
User avatar
johnhpus
Platinum Sponsor
Platinum Sponsor
Posts: 1186
Joined: Sat Apr 17, 2004 2:49 am
x 3

Post 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/
User avatar
nullsquared
Old One
Posts: 3245
Joined: Tue Apr 24, 2007 8:23 pm
Location: NY, NY, USA
x 11

Post 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.
User avatar
Game_Ender
Ogre Magi
Posts: 1269
Joined: Wed May 25, 2005 2:31 am
Location: Rockville, MD, USA

Post 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.
Post Reply