Sujet : Re: Which code style do you prefer the most?
De : janis_papanagnou+ng (at) *nospam* hotmail.com (Janis Papanagnou)
Groupes : comp.lang.cDate : 27. Feb 2025, 09:38:40
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vpp8ag$31ooi$1@dont-email.me>
References : 1 2 3 4 5 6 7 8
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0
On 27.02.2025 07:17, Lawrence D'Oliveiro wrote:
On Thu, 27 Feb 2025 07:06:22 +0100, Janis Papanagnou wrote:
Another reason (that I mentioned in a recent post) is that you restrict
your working quality [by not restricting line length] (for details see
that previous post).
Somebody is likely to bring this up sooner or later, so I might as well do
so.
It is a fact that reading text is faster with shorter line lengths. This
is why newspapers have more, narrower columns, as opposed to fewer, wider
ones. So why do I have such long lines?
In fact, the actual nonblank parts of my lines of source are not often
that long. So my choice of 100-column width is more to allow for levels of
indentation, rather than to be filled with long lines of text.
Yes, very true. - Actually I thought about mentioning that myself,
but I didn't want to open another can of worms.
What I yet did not say is that the texts we operate on in IT are
not the prose we find in books. There's more (structural!) factors
that play a role and also relevant operational semantics relations.
That said; there's still the upthread mentioned factors to consider
when readability is concerned. And a sensible line length is crucial.
Also note (WRT your newspaper comment) that the column width is even
much smaller than in prose books; typically <40 columns. But I don't
suggest to write 40 columns source text indented to arbitrary depth.
Reality looks different. In my case I use reduced Tab-indentation to
mostly 4 columns per indent, sometimes, depending on the source type,
just 2 columns. Too deep indenting I consider to be a possible bad
structuring effect, so that I sometimes have to refactor source code
and put some code in functions to make it better structured and more
readable. - I think we all observed such code evolutions, and we all
have own standards/conventions to keep our code legible (if only for
ourselves).
But much (if not all) of that, indenting, line lengths, etc. is just
preference anyway, mostly. It has to be sensibly defined or chosen,
though, where different people work together.
Janis