Enforcing fixed text width in source files
How strictly should one should stick to a fixed text width in source code files? More specifically, do you always abide by the 80-character limit for code and the 100- or 120-character limit for comments? Sometimes there are lines in my code in which I am hesitant to introduce a line break since it would disrupt the uniformity or reduce the legibility of the surrounding code. Do you use your discretion in these cases, or always c开发者_如何转开发hoose to abide by the text width?
I've run into these situations before as well. While I use the 80 characters as a guideline, I give uniformity a higher priority, so I feel free to exceed the limit if it maintains clarity.
The reason I'm okay with exceeding the limit is that most people these days (at least people I work with) have editors / screens which are easily capable of displaying well over 100 chars, so exceeding 80 does not impede the readability of the code.
While the limit generally helps to keep code readable, I find that if I always try to maintain the limit, then, like you said, the flow of the code, and therefore it's readability, is disrupted.
It would depend on why you are seeking to enforce a limit?
Is the code yours alone, or is it shared with many others? Are you creating source that will be viewed and augmented by one other person, a dozen people, hundreds? The more people who are using/viewing, the better it is to have uniformity.
Of course, you also make a good argument for not limiting...
Sometimes there are lines in my code in which I am hesitant to introduce a line break since it would disrupt the uniformity or reduce the legibility of the surrounding code.
My two cents.
精彩评论