Number of characters per line of code

  • Thread starter Thread starter Brian Gideon
  • Start date Start date
B

Brian Gideon

All,

I want to know how others deal with long lines of code. Do you care?
If so, what rule(s) do you follow? Is it important to you how it looks
on printed paper or displayed on the screen? Being able to keep all of
the code on the screen without scrolling horizontally is important to
me, but the 80 character rule is limiting and outdated and anything
else seems arbitrary considering that different developers use
different screen resolutions, fonts, IDE layouts, etc.

Brian
 
Brian,

Well, you can't really go by character count because of the things you
said. All things considered, usually in VS.NET when developing, I have the
project explorer pinned, and I have the server explorer/toolbar hidden (in
fly-out mode). Once I have that setup, with the default font settings and a
system with a 1280x1024 resolution, I try and make sure that one line of
code does not wrap past the available real estate in the code editor.

I've found that placing the server explorer/toolbox window in fly-away
mode gives me a good amount of real estate to work with, and gives me good
boundaries for the code in the file.

Hope this helps.
 
I started out wrapping lines manually, but then ran into trouble. I
have two screens at two different resolutions (aging eyes), plus the
printed page, which is different again and can be portrait or
landscape. No matter how I chose my wrap points, the line wrapping
looked like a mess in some situations.

Now I don't wrap, except at very obvious wrap points (nested method
calls, etc). I let the line get as long as it wants to be, and I have
Tools -> Options -> Text Editor -> C# -> Word Wrap turned on, so that
Visual Studio wraps the lines for me.

That way, no matter where I move the VS window, or how I print the
text, VS wraps the lines as required.

Yes, you have to get used to reading wrapped lines, but there are no
horizontal scroll bars, and the source code looks equally good (or
equally bad) in all situations.
 
Bruce Wood said:
Yes, you have to get used to reading wrapped lines, but there are no
horizontal scroll bars

Minor point: you can hide the horizontal scroll bar even with word wrapping
turned off in VS.NET (2003 -- dunno whether or not this holds true for
other versions).
 
Yeah, 80 characters are really too limiting for the looong identifiers
in the CLR library, let alone XML comment tags... I've recently
converted my C# code to 100 CPL, that's a decent compromise between
not having to break too many lines vs not exceeding screen space.
 
Back
Top