[program-l] Re: Indentation of code

  • From: Jamal Mazrui <empower@xxxxxxxxx>
  • To: program-l <program-l@xxxxxxxxxxxxx>
  • Date: Thu, 20 May 2010 16:55:59 -0400 (EDT)

I find that to be a rather arogant, judgmental statement. If a compiler does not care about indentation, then clearly it is not important to the functioning of the code, which is its ultimate purpose. Indentation is almost inherently visual in its benefit (excepting a good braille reader who gets something out of scanning down for changes in margin). Sighted programmers do not use techniques just for the benfit of blind programmers when they are not beneficial to themselves, and I am not under such an obligation to them when working as an individual.


I assure you that users of an application to not give a hoot how the code is formatted: they care what the program does!

Jamal
On Thu, 20 May 2010, Soronel Haetir wrote:

Date: Thu, 20 May 2010 12:41:11 -0800
From: Soronel Haetir <soronel.haetir@xxxxxxxxx>
Reply-To: program-l@xxxxxxxxxxxxx
To: program-l <program-l@xxxxxxxxxxxxx>
Subject: [program-l] Re: Indentation of code

I see some degree of code formatting as being similar to choosing
decent variable names and other such items.  Not doing it shows either
sloppiness or a lack of knowledge.  That doesn't mean you have to be
as consistent as a pretty printer would make it but not using
indentation at all quickly makes code extremely difficult to follow
and would make me question what other best practices the author
tossed.

Auto-generated code I see as being a different beast entirely.  Sure,
you might be able to do something more elegantly than the generated
code, but you have to weigh that against the time required to do it
yourself.  A lot of the time that effort can be better spent
elsewhere.  In a way I see that being more similar to the arguments
about whether to even use a compiler or to write things in assembly
language.  There are (rare) times when it is necessary to go to that
level but usually the payoff isn't worth the price.


On 5/20/10, Jamal Mazrui <empower@xxxxxxxxx> wrote:
An additional point is as follows.  VS automatically indents code, but why
should code asthetics be judged so heavily on that basis as some people
seem to imply (not targeted to anyone in particular)?  VS also generates
reams of code, particularly the forms designer, when the same thing can
be accomplished more succinctly and elegantly in hand crafted code.  If
someone is going to judge the asthetics of my code, I hope the whole
package is considered, not just a particular visual aspect -- one that can
be readily changed with an auto formatter.

Jamal

On Thu, 20 May 2010,
Jamal Mazrui wrote:

Date: Thu, 20 May 2010 16:17:03 -0400 (EDT)
From: Jamal Mazrui <empower@xxxxxxxxx>
Reply-To: program-l@xxxxxxxxxxxxx
To: program-l@xxxxxxxxxxxxx
Subject: [program-l] Re: Indentation of code

I code almost exclusively in an editor I have developed, EdSharp, rather
than
in Visual Studio.  Although I worked extensively on JAWS scripts for VS, I

find EdSharp more productive for me.  I am speaking for myself, and have
no
problem with others preferring another environment, VS or otherwise.

EdSharp does not automatically indent code because it does not know the
structure of the language being used.  So, indentation has to be managed
manually.  I have created hotkeys to help with this in various ways. For
example, Alt+Home goes to the first nonblank character on the line.
Control+I
moves down to the next change in indentation, and Control+Shift+I moves
upward.  Alt+I announces the current indentation level.  There are other
hotkeys as well.

So, it is quite possible to manually manage indentation in EdSharp, and I
do
so with the Python language, which requires it.  This does involve a
significant amount of time and effort, however, which detracts from my
coding
productivity otherwise.

I do try to use mnemonic variable names, and in fact, still prefer
Hungarian
notation (even though not the .NET convention) because I think it is
helpful
to know at least primitive data types when reading code. I often use a
blank
line to sepearate blocks, and make use of comments when there is a risk of

confusion about what code structure I am reading.

As mentioned, my coding has been as an individual, not part of a team, so
I
am not constrained the way others understandably are.  I think that if a
sighted person is truly interested in my code, it is a trivial matter to
use
an auto formatter to add the indentation style desired. Much more time
would
be involved in understanding what the code does conceptually than in
applying
an auto formatter for visual asthetics.

I have coded with and without the need to manage indentation, and can say
with confidence that indentation is a productivity drain for me. The fact
that many blind people have difficulty programming in Python because of
the
indentation requirement is evidence of a similar experience for them.  The

most important thing about code is whether it gets the job done, not how
pretty it is.  Of course, other things being equal, it is nice for code to
be
pretty as well.  I find that they are not equal, however, there is a trade

off, and I choose to work in nonvisual ways that work best for what I am
trying to accomplish.

Different strokes for different folks.

Jamal
On Thu, 20 May 2010, David Lant wrote:

Date: Thu, 20 May 2010 20:49:10 +0100
From: David Lant <david.lant1@xxxxxxxxxxxxxx>
Reply-To: program-l@xxxxxxxxxxxxx
To: program-l@xxxxxxxxxxxxx
Subject: [program-l] Re: Indentation of code

The thing is, I can't think of any reason why a blind developer should
not
indent though.  You say it causes problems with moving to the start of a
line, but that's a feature of the editor, not code indentation.  e.g. in
Visual Studio, if I hit the home key on a line of code, the first time it
will take me to the first non-blank character on that line.  the second
press will take me to the first column.  It's so quick and easy to do it
really isn't an overhead at all.  And it does this without any JAWS
scripts
involved.

As I've mentioned elsewhere, where the editor automatically formats code
as
you type it, indentation and formatting doesn't even become a
consideration
because it happens without your involvement.  Even copying and pasting
code
automatically rearranges the layout to suit the code structures involved.
Maybe I'm just spoiled by using Visual Basic.  but having come from a
COBOL,
PL/1 and Natural background, manually indenting code just becomes a
habit.
Even on the mainframe I used to work on, the Natural editor used to
provide
structured formatting features.  So it's nothing new.  I've been
programming
for 24 years now, and I've never yet had a problem with it.

I can understand how indentation might be distracting for a braille user,
but depending on the width of the braille display, it wouldn't seem to be

a
major problem.  After all, many source code editors allow code to extend
beyond the average width of a braille display so I imagine you'd be
scrolling left and right to read long lines too, for example.
Indentation
wouldn't seem any worse than that to me.  Having the ability to quickly
scan
down code to locate particular structures or blocks would seem
advantageous.
I have vaguely considered getting a braille display for the added
orientation information it might give.  I guess I've got on without one
for
so long now though, it's not likely to happen.

If you're just writing code for yourself, then one could say that all the
normal good practice guidelines for coding could be ignored.  formatting,
meaningful variable names, commented code etc would all seem unnecessary.
However, I challenge any developer to prove unequivocally that any code
they
write will never be seen by anyone else.  Even in situations when I
thought
that was the case when writing a quick one-off utility or other, I've
always
ended up finding another use for it that someone else ends up seeing.  So

in
the end it's just quicker and easier to code in a structured and
formatted,
well documented and human readable way.

Having said all this, I do have to admit that the worst structured and
laid
out code I ever came across was written by a fully sighted person.  It
was
so arcane and unmaintainable that it seemed like a deliberate ploy by
that
individual to make themselves indispensible.  If they were the only
person
who could make head or tail of the code, then surely they'd always have a
job?  Well, auto-formatting and code analysis utilities soon put paid to
that. :-)

All the best,

David

David Lant
Applications analyst

MCPD Enterprise Application Development 3.5
MCTS ASP.NET 3.5, ADO.NET 3.5, Windows Communication Foundation 3.5,
Windows
Applications 3.5

-----Original Message-----
From: program-l-bounce@xxxxxxxxxxxxx
[mailto:program-l-bounce@xxxxxxxxxxxxx]
On Behalf Of Jamal Mazrui
Sent: 20 May 2010 12:47
To: program-l@xxxxxxxxxxxxx
Cc: Amanda Lacy; Doug Lee
Subject: [program-l] Re: Indentation of code

Personally, as a speech-only user, I find indentation to be of no
benefit.  In fact, I find it to be an efficiency drain in coding.  I
cannot simply press Home to go to the start of code on a line.  When
cutting and pasting code, it has to be adjusted to make indentation
align.  I know there are hotkey work-arounds for this, but they involve
more effort than when indentation is not a concern.  Rather than using
indentation to help me follow code structure, I find it more productive
to use a short in-line comment at the end of a block to remind me what
structure it is completing.

With that said, I understand that indentation is needed for usability of
code by sighted readers, as well as good braille  readers (I read
braille but am too slow to benefit from a braille display if speech is
available).  I realize that if I coded in a team, I would always have to
indent my code.  I also know that if I want a sighted person to work
with nontrivial code, I need to use an auto-formatter before sharing it.

Just because indentation is optimal for sighted programmers does not
mean it is so for blind programmers.  They do not use some of our
nonvisual techniques, and we do not need to use all their visual
techniques. In a language that does not require indentation, an
auto-formatter will indent more correctly than manually doing so.

Jamal

On 5/19/2010 10:08 PM, Amanda Lacy wrote:
Am I the only one who thinks indentation makes code harder to read? I
focus on the information itself, and when much of my braille display
is consumed by space I find it a destraction. I have yet to understand
its use.

On 5/19/10, Doug Lee<dgl@xxxxxxxx>  wrote:
For what it's worth, I strongly prefer using tabs and not spaces:  Tab
width can be varied by the user with no changes to the code, using
tabs means one character per indent instead of the average three or
four spaces, tabs can be displayed as printable characters like ^I in
some editors in case checking indents is a problem for some reason,
and one can translate tabs to the normal two spaces before Brailling a
listing if necessary.  As a rule, if I see spaces for indenting in a
program, I imitate what's there if I'm making small changes, but I
replace them all with tabs if I'm taking over the file.

On Wed, May 19, 2010 at 02:35:45PM -0600, Tyler Littlefield wrote:
I had to switch the tabs to spaces in python, so that I could read
other code. No idea why edsharp defaults to tabs, and whether you'll
be aloud to use spaces, you have to use \40 I believe to get a space.
----- Original Message ----- From: "?yvind Lode"
<oyvind.lode@xxxxxxxx>
To:<program-l@xxxxxxxxxxxxx>
Sent: Wednesday, May 19, 2010 2:19 PM
Subject: [program-l] Re: Indentation of code


Hi:

I currently don't have any preferred style of indentation.
EdSharp defaults to tab indentation.
But I feel it's a waste of cells on my Braille display he he.
But I'll probably find my preferred way of indentation the more code
I
write.
Reading source code written by other programmers is probably also a
good
idea.

-----Original Message-----
From: program-l-bounce@xxxxxxxxxxxxx
[mailto:program-l-bounce@xxxxxxxxxxxxx]
On Behalf Of David Lant
Sent: 19. mai 2010 21:13
To: program-l@xxxxxxxxxxxxx
Subject: [program-l] Re: Indentation of code

Hi,

Yes, I always indent code.  However, this may make it sound like I
actually
do anything to achieve this.  Using Visual Studio, coding in either
VB
or
C#, it is possible to have the editor automatically do all the
indenting for
you, so you don't even need to think about it.  This is especially
well
implemented for VB, but does appear for C# too.

There is no reason at all why a blind developer shouldn't indent
code.
It
doesn't add any overhead to reading the code back, as any leading
spaces can
be ignored by a screen reader.  If you really want to know how your
code is
indented, then I'm sure most if not all of them include a feature to
tell
you what the indentation of the current line is.

If you have a particular layout style that you like, which is
different from
that used by your editor of choice, you can always go into the
Options
and
change the settings.  The simplest thing of course is  to change how
many
spaces are indented and whether this is done by adding leading
spaces or
adding tabs.  But there are other options you can play with as well,
up
to
and including turning off automatic formatting altogether.

Sighted people always prefer code to be formatted so they can easily
scan
the layout and both identify the overall structure and locate
particular
constructs.  So whether you're expecting to show code to a sighted
person or
not, I'd always recommend getting into the habit of indenting and
formatting
neatly.

All the best,

David

David Lant
Applications analyst

MCPD Enterprise Application Development 3.5
MCTS ASP.NET 3.5, ADO.NET 3.5, Windows Communication Foundation 3.5,
Windows
Applications 3.5

-----Original Message-----
From: program-l-bounce@xxxxxxxxxxxxx
[mailto:program-l-bounce@xxxxxxxxxxxxx]
On Behalf Of ?yvind Lode
Sent: 19 May 2010 16:55
To: programmingblind@xxxxxxxxxxxxx; program-l@xxxxxxxxxxxxx
Subject: [program-l] Indentation of code

Hi all:

I'm just wondering how you folks indent your code?
Do you use indentation at all?

I know that indentation is not required for C#, but sighted folks
prefer it.

Currently I don't have any code to share between sighted and blind
programmers.
I've just started learning to program and I use C#.

I'm just curious and would like some pointers.
I'm just trying to develop a good habit of how my code should look
like.

** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq

** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq

** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq

** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq

--
Doug Lee                 dgl@xxxxxxxx
http://www.dlee.org
SSB BART Group           doug.lee@xxxxxxxxxxxxxxxx
http://www.ssbbartgroup.com
The very smart may feel they have nothing to learn from anyone;
The very wise will find something to learn from everyone.  (7/14/01)
** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq

** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq

** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq

** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq

** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq

** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq



--
Soronel Haetir
soronel.haetir@xxxxxxxxx
** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq

** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq

Other related posts: