We use coding standard of 80 characters in line. The original reason for 80 char limitation is not relevant today, but some number should be picked...
Beside the obvious (code organization and readability) usually i found that long lines are result of bad styling and folowing such rule improve code quality and reduce errors. Just compare the following examples :
status = do_something();
if (status == error)
{
do_error_handling();
return;
}
/* do you regular flow */
status = do_more();
if (status == error)
{
do_error_handling();
return;
}
/* do more of you regular flow and keep you line 80 chars*/
instead :
status = do_something();
if (status == succes)
{
/* do you regular flow */
status = do_more();
if (status == success)
{
/* do you regular flow */
/* nest again and get line behind visible screen */
}
else
{
/* do error handling */
}
}
else
{
/* do error handling */
}
Second example is much less readable hard to maintain and probably will lead to some problem on the way ...
Edit
Replaced goto
with do_error_handling()
in the code to avoid not relevant discussion.
As i stated before 80 characters not relevant today it's just a number 100 is good as well.
For anyone that found second example more readable please nest it few more times with real code and try read again :)