Deutsch   English   Français   Italiano  
<vq1pgp$pskj$2@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!weretis.net!feeder9.news.weretis.net!news.quux.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: bart <bc@freeuk.com>
Newsgroups: comp.lang.c
Subject: Re: Which code style do you prefer the most?
Date: Sun, 2 Mar 2025 14:21:13 +0000
Organization: A noiseless patient Spider
Lines: 74
Message-ID: <vq1pgp$pskj$2@dont-email.me>
References: <vpkmq0$21php$1@dont-email.me> <vpl62m$250af$1@dont-email.me>
 <87frk10w51.fsf@onesoftnet.eu.org> <vpn8vs$2jmv1$1@dont-email.me>
 <vpn92i$86q$1@reader1.panix.com> <vpodnf$2q6ak$4@dont-email.me>
 <vpovd0$30d00$1@dont-email.me> <vpp011$30evb$1@dont-email.me>
 <vpp8ag$31ooi$1@dont-email.me> <vppaeq$323aa$1@dont-email.me>
 <vprpss$3ipmu$1@dont-email.me> <86ldtnwneg.fsf@linuxsc.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 02 Mar 2025 15:21:13 +0100 (CET)
Injection-Info: dont-email.me; posting-host="14c3d5cad90d090968edda894fc8ea67";
	logging-data="848531"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/uZZsHOlj07xKzhMCZu2Z5"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:yiENMBQhFXVwSyqkuX8pgH9/jqk=
Content-Language: en-GB
In-Reply-To: <86ldtnwneg.fsf@linuxsc.com>
Bytes: 3783

On 02/03/2025 13:52, Tim Rentsch wrote:
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
> 
>> 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
> 
> This measurement is an interesting idea.
> 
> Gathering some statistics from what I expect is typical source for
> my own code, and ignoring: blank lines; lines that are flush left;
> and "non-code" lines; I get
> 
>     level  percent  percentile
>     =====  =======  ==========
>         1     69.6        69.6
>         2     27.0        96.5
>         3      2.2        98.7
>         4      0.9        99.6
>         5      0.4       100.0
> 
> giving an average indentation of 1.36 levels.  The numbers shown are
> calculated by considering the amount of leading white space in each line,
> and rounding up to an integral multiple of one indent level (which
> is four columns).

I tried it on a non-C project and the results were:

Level  Count  Percentage

  1     11843   52%
  2      6659   29%
  3      3016   13%
  4      1016    4%
  5       366    2%
  6        79    0%
  7        15    0%

Total  22994  100%

Total project size was 29K lines. Comments are ignored. Level 0 lines 
are ignored.

All function bodies are indented one level anyway, so half the lines 
aren't indented at all relative to the baseline.

The highest indent is 7, but since tabs are 4 spaces, those lines only 
start 28 characters in from the left, in a 100-char window. That's 24 
characters beyond the 'baseline'.