473,698 Members | 2,833 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.

Oct 9 '08
53 12115
blargg wrote:
In article <12************ ***@irys.nyx.ne t>, yt******@nyx.ny x.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.
Oct 15 '08 #51
On Oct 15, 3:04*pm, blargg....@gish puppy.com (blargg) wrote:
In article <1224061250.227 ...@irys.nyx.ne t>, ytrem...@nyx.ny x.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 objektorientier ter Datenverarbeitu ng
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...@michae ldadmum.no-ip.orgwrote:
>Gianni Mariani wrote:
>>Do you have a preference on maximum line width for C++ code?

>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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

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_
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...
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,...
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...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
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...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
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...
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.