Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #23890 > unrolled thread

Re: Indentation styles

Started byEric Sosman <esosman@comcast-dot-net.invalid>
First post2013-05-07 10:56 -0400
Last post2013-05-12 23:21 -0400
Articles 3 — 2 participants

Back to article view | Back to comp.lang.java.programmer

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Indentation styles Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-05-07 10:56 -0400
    Re: Indentation styles Arne Vajhøj <arne@vajhoej.dk> - 2013-05-12 22:04 -0400
      Re: Indentation styles Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-05-12 23:21 -0400

#23890 — Re: Indentation styles

FromEric Sosman <esosman@comcast-dot-net.invalid>
Date2013-05-07 10:56 -0400
SubjectRe: Indentation styles
Message-ID<kmb4h3$mnj$1@dont-email.me>
On 5/7/2013 10:23 AM, Stefan Ram wrote:
>[...]
>    An indentation of just one space often is too small to be seen
>    clearly, because the natural width and form of characters
>    often varies by an amount that is not very much smaller than a
>    space. Therefore, the indentation should amount to at least
>    two positions. In order not to waste horizontal spaces, an
>    indentation of exactly two positions is chosen. This means,
>    that the left position of the next level is two larger than
>    the position of the directly enclosing level.
> [...]

     I dimly recall reading, long ago, of someone's actual attempt
to measure the readability of different indentation widths.  Alas,
I can no longer find the reference.  I believe, though, that the
experiments found two spaces too narrow, four spaces too wide, and
eight spaces much too wide.

     Unfortunately, the remaining span includes two of the most
prominent and pervasive numbers of all, and there's no hint as to
which to use: The One True Best Indentation Width might be π or
it might be e, and I expect the religious debates on the topic
will rage endlessly.  Personally, I adopt a tolerant stance: Use
either e spaces or π spaces according to the teachings of your
faith.  Using anything else, though, would be heresy.  :)

-- 
Eric Sosman
esosman@comcast-dot-net.invalid

[toc] | [next] | [standalone]


#24025

FromArne Vajhøj <arne@vajhoej.dk>
Date2013-05-12 22:04 -0400
Message-ID<51904a4a$0$32109$14726298@news.sunsite.dk>
In reply to#23890
On 5/7/2013 10:56 AM, Eric Sosman wrote:
> On 5/7/2013 10:23 AM, Stefan Ram wrote:
>> [...]
>>    An indentation of just one space often is too small to be seen
>>    clearly, because the natural width and form of characters
>>    often varies by an amount that is not very much smaller than a
>>    space. Therefore, the indentation should amount to at least
>>    two positions. In order not to waste horizontal spaces, an
>>    indentation of exactly two positions is chosen. This means,
>>    that the left position of the next level is two larger than
>>    the position of the directly enclosing level.
>> [...]
>
>      I dimly recall reading, long ago, of someone's actual attempt
> to measure the readability of different indentation widths.  Alas,
> I can no longer find the reference.  I believe, though, that the
> experiments found two spaces too narrow, four spaces too wide, and
> eight spaces much too wide.
>
>      Unfortunately, the remaining span includes two of the most
> prominent and pervasive numbers of all, and there's no hint as to
> which to use: The One True Best Indentation Width might be π or
> it might be e, and I expect the religious debates on the topic
> will rage endlessly.  Personally, I adopt a tolerant stance: Use
> either e spaces or π spaces according to the teachings of your
> faith.  Using anything else, though, would be heresy.  :)

I sure someone has tried measuring what is optimal, but I
suspect that the difference were pretty small (for realistic
indentations).

But I am sure that it could be measured that the effect
of using the same indentation level in a file is huge and
I strongly suspect the same for using the same in a project.

Which leads to the normal conclusion:
* make a decision about indentation level and stick to it
* if there are no strong opinions about it then go with the
   industry standard for that language (4 for Java)

Arne

[toc] | [prev] | [next] | [standalone]


#24029

FromEric Sosman <esosman@comcast-dot-net.invalid>
Date2013-05-12 23:21 -0400
Message-ID<kmplvt$rk7$1@dont-email.me>
In reply to#24025
On 5/12/2013 10:04 PM, Arne Vajhøj wrote:
> On 5/7/2013 10:56 AM, Eric Sosman wrote:
>> On 5/7/2013 10:23 AM, Stefan Ram wrote:
>>> [...]
>>>    An indentation of just one space often is too small to be seen
>>>    clearly, because the natural width and form of characters
>>>    often varies by an amount that is not very much smaller than a
>>>    space. Therefore, the indentation should amount to at least
>>>    two positions. In order not to waste horizontal spaces, an
>>>    indentation of exactly two positions is chosen. This means,
>>>    that the left position of the next level is two larger than
>>>    the position of the directly enclosing level.
>>> [...]
>>
>>      I dimly recall reading, long ago, of someone's actual attempt
>> to measure the readability of different indentation widths.  Alas,
>> I can no longer find the reference.  I believe, though, that the
>> experiments found two spaces too narrow, four spaces too wide, and
>> eight spaces much too wide.
>>
>>      Unfortunately, the remaining span includes two of the most
>> prominent and pervasive numbers of all, and there's no hint as to
>> which to use: The One True Best Indentation Width might be π or
>> it might be e, and I expect the religious debates on the topic
>> will rage endlessly.  Personally, I adopt a tolerant stance: Use
>> either e spaces or π spaces according to the teachings of your
>> faith.  Using anything else, though, would be heresy.  :)
>
> I sure someone has tried measuring what is optimal, but I
> suspect that the difference were pretty small (for realistic
> indentations).
>
> But I am sure that it could be measured that the effect
> of using the same indentation level in a file is huge and
> I strongly suspect the same for using the same in a project.
>
> Which leads to the normal conclusion:
> * make a decision about indentation level and stick to it
> * if there are no strong opinions about it then go with the
>    industry standard for that language (4 for Java)

     It would be both instructive and liberating, I think, to
adopt indentation widths that are multiples of i.  Instead of
pushing the indented line to the right and thereby reducing
the amount of non-white horizontal space available, a pure
imaginary indent would move the text in a direction normal to
the page or display surface: Nearer to the viewer for c*i
with c>0, or further into the background for c<0.  The sign
of c could be adjusted automatically by code inspection tools,
positive when the programmer is trying to study the excruciating
details of the code and wants to deep-dive on the interiors of
conditions and loops, or negative when the focus is on the Big
Picture and petty details shouldn't get in the way.

     Given the two-dimensional nature of most display surfaces,
plus a third dimension toward or away from the viewer, one might
be tempted to employ indentation standards based on quaternions.
Any "one" so tempted is urged to seek psychiatric help.  NOW.

-- 
Eric Sosman
esosman@comcast-dot-net.invalid

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web