473,705 Members | 2,333 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 12121
After takin' a swig o' grog, James Kanze belched out
this bit o' wisdom:
On Oct 10, 1:42 pm, Chris Ahlstrom <lino...@bollso uth.nutwrote:
>After takin' a swig o' grog, James Kanze belched out
this bit o' wisdom:
So as a general rule: a maximum of 80 characters, total, and
between 60 and 70, without the leading indentation.
>Check out Ch. 32 of BEAUTIFUL CODE, entitled "Code in Motion".
Here's the article it is based on:
> http://www.perforce.com/perforce/papers/prettycode.html
> Seven Pillars of Pretty Code
> Christopher Seiwald

Which starts well, and gets worse as it goes along, ending up
with some of the worst coding practices imaginable.
Guess it's all a matter of taste, then.

--
You will be successful in love.
Oct 10 '08 #21
James Kanze wrote:
On Oct 10, 1:42 pm, Chris Ahlstrom <lino...@bollso uth.nutwrote:
>After takin' a swig o' grog, James Kanze belched out
this bit o' wisdom:
>>So as a general rule: a maximum of 80 characters, total, and
between 60 and 70, without the leading indentation.
>Check out Ch. 32 of BEAUTIFUL CODE, entitled "Code in Motion".
Here's the article it is based on:
> http://www.perforce.com/perforce/papers/prettycode.html
> Seven Pillars of Pretty Code
> Christopher Seiwald

Which starts well, and gets worse as it goes along, ending up
with some of the worst coding practices imaginable.
I'm with you there, horrible.

Use goto to avoid indentation, what was he thinking?

--
Ian Collins
Oct 10 '08 #22
Gianni Mariani wrote:
>
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.
80. Period. Please. It's a hard and fast rule. It's not hard
(despite your claim of "oodles" of wasted time), and it makes my life a
heck of a lot easier.
Oct 10 '08 #23
On Oct 10, 8:31*pm, Chris Ahlstrom <lino...@bollso uth.nutwrote:
After takin' a swig o' grog, James Kanze belched out
* this bit o' wisdom:
On Oct 10, 1:42 pm, Chris Ahlstrom <lino...@bollso uth.nutwrote:
After takin' a swig o' grog, James Kanze belched out
* this bit o' wisdom:
So as a general rule: a maximum of 80 characters, total, and
between 60 and 70, without the leading indentation.
Check out Ch. 32 of BEAUTIFUL CODE, entitled "Code in Motion".
Here's the article it is based on:
* *http://www.perforce.com/perforce/papers/prettycode.html
* *Seven Pillars of Pretty Code
* *Christopher Seiwald
Which starts well, and gets worse as it goes along, ending up
with some of the worst coding practices imaginable.
Guess it's all a matter of taste, then.
Not really. Some things are a matter of taste, but some of his
recommendations involve proven bad practice. I'd avoid that
site like the plague.

--
James Kanze (GABI Software) email:ja******* **@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Oct 10 '08 #24
On Oct 10, 9:57*am, Victor Bazarov <v.Abaza...@com Acast.netwrote:
James Kanze wrote:
But I don't see where that really makes a difference. *If I'm
editing with a card punch, I have an even more rigorous set of
constraints.

Are you *reading* the cards? *If you're not, how is *readability*
involved? *Wasn't that the issue the OP brought forth? *The cards need
to be readable, but not by a human.

They have to be readable if you're editing. While we did read the
*programs* off printed listings, you still had to dig into the decks
to make the changes. And for that you had to read the card - which
was why, for source code, you almost always had the text printed
across the top of the card.
Oct 10 '08 #25
James Kanze wrote:
(On the other hand, like everyone else, I'll copy/paste my
code directly from the original source, so if I post actual
code from elsewhere, it is wider. And its formatting does
get messed up.)
Your newsreader may have an option not to wrap outgoing lines. Of
course you'd have to get the prose part wrapped some other way, but
even doing that manually is rather less hazardous than doctoring
pasted code.
Martin

--
He who can be himself shall belong to no one else.
--Paracelsus
Oct 10 '08 #26
ro***********@y ahoo.com wrote:
On Oct 10, 9:57 am, Victor Bazarov <v.Abaza...@com Acast.netwrote:
>James Kanze wrote:
>>But I don't see where that really makes a difference. If I'm
editing with a card punch, I have an even more rigorous set of
constraints .
Are you *reading* the cards? If you're not, how is *readability*
involved? Wasn't that the issue the OP brought forth? The cards need
to be readable, but not by a human.


They have to be readable if you're editing. While we did read the
*programs* off printed listings, you still had to dig into the decks
to make the changes. And for that you had to read the card - which
was why, for source code, you almost always had the text printed
across the top of the card.
Not all card punchers could do that. What we had is a number on the
card that would be the same as the line number on the source printout.
You would *never* have to actually read the card to understand what the
code is doing (which is where the readability is important). You would
only need to read the card to make sure it's the right one just before
replacing it with the updated, in the stack.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Oct 10 '08 #27
Martin Eisenberg wrote:
James Kanze wrote:
(On the other hand, like everyone else, I'll copy/paste my
code directly from the original source, so if I post actual
code from elsewhere, it is wider. And its formatting does
get messed up.)

Your newsreader may have an option not to wrap outgoing lines.
His news system is Google Groups. That doesn't have many options.


Brian
Oct 10 '08 #28
James Kanze wrote:
On Oct 10, 10:13 am, Hendrik Schober <spamt...@gmx.d ewrote:
>Chris Ahlstrom wrote:
>>After takin' a swig o' grog, Erik Wikström belched out
this bit o' wisdom:

[...]
> (But then I had never had to look at code at a machine which
only has vi. And hopefully I'll never will. :^)

Not sure what vi has to do with it. Vi displays in whatever the
window width is.
I already answered this.
The problem is things like the size of paper,
for example (my printer won't handle much larger than A4).
I can't remember the last time I printed code.
[...]
Schobi
Oct 10 '08 #29
On Oct 10, 4:20*pm, Victor Bazarov <v.Abaza...@com Acast.netwrote:
robertwess...@y ahoo.com wrote:
On Oct 10, 9:57 am, Victor Bazarov <v.Abaza...@com Acast.netwrote:
James Kanze wrote:
But I don't see where that really makes a difference. *If I'm
editing with a card punch, I have an even more rigorous set of
constraints.
Are you *reading* the cards? *If you're not, how is *readability*
involved? *Wasn't that the issue the OP brought forth? *The cards need
to be readable, but not by a human.
They have to be readable if you're editing. *While we did read the
*programs* off printed listings, you still had to dig into the decks
to make the changes. *And for that you had to read the card - which
was why, for source code, you almost always had the text printed
across the top of the card.

Not all card punchers could do that. *What we had is a number on the
card that would be the same as the line number on the source printout.
You would *never* have to actually read the card to understand what the
code is doing (which is where the readability is important). *You would
only need to read the card to make sure it's the right one just before
replacing it with the updated, in the stack.

By the time the late 60s rolled around, almost all keypunches had, at
least as an option, an "interpret" feature which did the printing. In
the IBM world, you had to go back to the '024 keypunch if you wanted
one that didn't print (its more popular, and otherwise identical,
sibling the '026, did print ). The ‘024 and ‘026 date back to 1949,
and were replaced by the ‘029, which did print, in 1964.

Not to say that I didn’t see more than a few keypunches with broken
printers.

The most common cases where I saw uninterpreted decks was after a deck
was punched from the mainframe, either from a library, or a
duplication of a worn out deck, on the "big" card punch, which
invariable didn't have such a feature. And those were always more of
a pain to deal with because the cards were that much harder to read.

For the life of me I can’t remember which device it was, but there was
a keypunch that had an “interpret existing deck” feature, which you
could feed a deck through it and get it interpreted. Only saw them in
a couple of shops, but they were rather handy at times.
Oct 11 '08 #30

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1473
by: Robert | last post by:
dear sir: I have read the c++ primer plus 5 book, and do the chapter 12 programming exercises question 5, but the average_wait have negative result. I don't understand why? here is the code, thank you anyone replay me.:) /************************* customer.h *************************/ #ifndef CUSTOMER_H_ #define CUSTOMER_H_
0
8767
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8689
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9273
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9030
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7893
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6605
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4439
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4703
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2486
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.