Sujet : Re: Which code style do you prefer the most?
De : janis_papanagnou+ng (at) *nospam* hotmail.com (Janis Papanagnou)
Groupes : comp.lang.cDate : 28. Feb 2025, 08:50:51
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vprpss$3ipmu$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0
On 27.02.2025 10:15, Lawrence D'Oliveiro wrote:
On Thu, 27 Feb 2025 09:38:40 +0100, Janis Papanagnou wrote:
Too deep indenting I consider to be a possible bad structuring
effect ...
Would you consider half a dozen indentation levels to be too many? I
frequently go that deep.
To be honest, I've never counted them. So why should I suggest someone
else what's a "good" value. Programmers certainly should have got (or
develop) a feeling about what's acceptable and what's too much in their
own playground (or in project contexts where many people cooperate).
But since you were asking I got curious; I pick one recent "C" source
from one of my toy projects and get this distribution of the amount of
indents
80 - // empty lines
169 0
254 1
172 2
122 3
46 4
34 5
7 6
3 7
What would be your typical indent distribution in your "C" source code?
(I wouldn't expect something completely different, but I also wouldn't
care if there would be.)[*]
Janis
PS: Note that your frequent indents of level 6 would in my setting with
a TAB of four mean 24 colums and would leave (for an 80 column window)
still 56 columns for "C" statements (in case you don't want to pass the
limit).
PPS: In the mentioned toy project I have 849 lines that stay within 80
columns and 38 lines that exceed that limit; the histogram distribution
N line length range
172 1-10
128 11-20
106 21-30
90 31-40
68 41-50
51 51-60
100 61-70
134 71-80
28 81-90
8 91-100
2 101-110
where the upper range is in more detail sparsely defined by
amount line length
...
1 91
3 92
1 93
1 94
1 95
1 100
1 101
1 107
where the longer lines are not complex code but stem from lines with
(long) strings in fprintf() information. Lines with non-printf/string
code are generally of length <90, or even <85 (the one long getopt()
line also has a long string literal, as I got aware).
[*] BTW; my hypothesis is that the actual line length distribution is
depending on the used window sizes. I had observed that folks who use
wide editor windows (or IDEs with wide windows) create wider source
code. I usually use 80 columns editing windows and thus naturally get
an indication when to wrap lines (without actively thinking about it).