469,282 Members | 1,940 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,282 developers. It's quick & easy.

What's your maximum line size preference?


Do you have a preference on maximum line width for C++ code?

I've seen the craziest debates on this most silly of topic.

I have witnessed engineers spent oodles of time fiddling with line
breaks just to get it right. I find in general a prescriptive rule
makes for markedly less readable code, which unfortunately is a
subjective argument, however, the waste of time modifying code when it
does not need to is not.

I'm interested in knowing what you'all do.

G
Oct 9 '08
53 10939
blargg wrote:
In article <12***************@irys.nyx.net>, yt******@nyx.nyx.net (Yannick
Tremblay) wrote:

[...]
>Don't get me wrong. The huge majority of my code is less than 80
chars. I do appreciate narrow simple lines. Just that I dislike a
hard rule that nothing should ever be wider than 80 chars because IMO
it is outdated and results in lower readability.

If the huge majority of your code's lines are less than 80 characters, how
could limiting those few other lines make a big impact on readability?
Because it would disregard that there's a reason that they're
that long despite the guideline.
[...]
Schobi
Oct 15 '08 #51
On Oct 15, 3:04*pm, blargg....@gishpuppy.com (blargg) wrote:
In article <1224061250.227...@irys.nyx.net>, ytrem...@nyx.nyx.net (Yannick
Tremblay) wrote:
[...]
Don't get me wrong. *The huge majority of my code is less
than 80 chars. *I do appreciate narrow simple lines. *Just
that I dislike a hard rule that nothing should ever be wider
than 80 chars because IMO it is outdated and results in
lower readability.
If the huge majority of your code's lines are less than 80
characters, how could limiting those few other lines make a
big impact on readability?
Having made a very strong statement in favor of a hard limit,
I'll now take the other side: there have been a few times when
I've been very tempted to violate the limit, sometimes by a lot.
The most frequent case is statically initialized tables: it
would be very nice (and much more readable) if I could make each
line in the table a line in the source code.

[...]
I prefer guidelines with judgement applied. *
I agree; guides, not hard rules (in most cases).
Rule 0 of any guidelines: any other rule in the guideline can be
violated with sufficient motivation. Typically, in a larger
organization, it will mean that you'll have to get it signed off
by your boss, or the architecture team, or someone in Q&A; in
more typical orgainizations, all it really means is that you'll
have to defend it in code review, and convince the reviewers.

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Oct 15 '08 #52
On Wed, 15 Oct 2008 07:28:00 -0700 (PDT), Nick Keighley
<ni******************@hotmail.comwrote:
>and END-OF-FILE character?!
Obviously a Java programmer. They already had a one-class-per-file
rule years ago, irrespective of how trivial that class might be.

Obviously they've taken the idea further ;-)

Oct 15 '08 #53
Nick Keighley wrote:
On 15 Oct, 14:13, Michael <mich...@michaeldadmum.no-ip.orgwrote:
>Gianni Mariani wrote:
>>Do you have a preference on maximum line width for C++ code?

<snip>
>I will only insert an EOF character according to my own rule as follows:

1. After a semicolon
2. After the head part of conditional sentence (if, then, for, do,
while, switch, etc)
3. After {

and END-OF-FILE character?!
Sorry, it should be EOL (End-of-line).
Oct 16 '08 #54

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.