Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualKhatharr

Posted 11 January 2013 - 03:33 PM

I try to keep my lines to 70 characters or less. It means I don't have to scroll sideways to read the line when I'm splitting the screen in VS.

 

I find really long lines to be jarring as I try to read code. The eye settles into a back-and-forth of a few inches and then suddenly here's a line of 3 or 4 times the length. It breaks the process of reading smoothly.

 

I also find that super-long lines are either doing too much (doing math in arguments, etc) or else the function itself is designed to accept too many parameters. If a function needs a ton of information I prefer to package that as a POD struct and also ask questions about whether or not the function is doing more than it should. There are certainly cases where a function can need a lot of information, but I think not as often as certain APIs would indicate. Trying to figure out all of what such a function is more difficult as well since you have to sort of hunt down the commas or unfold the parenthesis (or whatever) mentally.

 

I don't know if there's really a magic number to it, but a kind of smoothness to the code body is what I hope for.


#1Khatharr

Posted 11 January 2013 - 03:32 PM

I try to keep my lines to 70 characters or less. It means I don't have to scroll sideways to read the line when I'm splitting the screen in VS.

 

I find really long lines to be jarring as I try to read code. The eye settles into a back-and-forth of a few inches and then suddenly here's a line of 3 or 4 times the length. It breaks the process of reading smoothly.

 

I also find that super-long lines are either doing too much (doing math in arguments, etc) or else the function itself is designed to accept too many parameters. If a function needs a ton of information I prefer to package that as a POD struct and also ask questions about whether or not the function is doing more than it should. There are certainly cases where a function can need a lot of information, but I think not as often as certain APIs would indicate. Trying to figure out all of what such a function is more difficult as well since you have to sort of hunt down the commas or unfold the parenthesis (or whatever) mentally.


PARTNERS