----------------------------------------
> Date: Wed, 2 Jan 2008 14:25:17 -0800
> From: [EMAIL PROTECTED]
> To: [email protected]
> Subject: Re: Introducing Cobra
> 
> SJS wrote:
>> Except that it *doesn't* improve readability.
>>
>> The eye *believes* whitespace, but it's also not very good at it.  It's
>> okay at determining that yeah, verily, there *is* whitespace, but it's
>> not very good at determining how much.  For very small programs, that's
>> okay; but these languages are no longer being used solely for small programs.
>>   
> If you honestly believed that, you shouldn't indent your code. In fact,
> as an experiment, I encourage you to compare your code before and after
> such a transformation. I assure you that the vast majority of the
> population will be more quickly able to determine the location of a
> start and end block when the block is properly indented with whitespace.
> 

The problem is that its much easier to get whitespace wrong than it is to get 
braces wrong.  For example-  one of my most frequent refactors is changing the 
nesting of a chunk of code-  either moving it into a loop, out of a loop, or 
into a new function. If you use braces, the code will work, but may be indented 
in an ugly matter.  If you do it with whitespace, it will be broken.

Now, your answer is that you need to fix this.  I agree.  Buyt while fixing it, 
you probably aren't only reindenting it-  you may be changing variable names, 
moving sub-blocks of it around, etc.  Or you may get a visitor and asked to 
look at something else in the middle of it.  THe end result is that its very 
easy to forget to indent a line or 2 properly while doing this.  If you have 
braces, the code still works and you have a visual cue as to where the 
indentation needs to be fixed.  If all you had is whitespace-  you're screwed.  
You'll figure it out when you find the bug it causes.

And if you mention auto-indent tools in editors-  if you need an editor to have 
a certain feature to avoid a common bug, you have a language flaw.

Just because its a best practice to indent (and it is) doesn't mean that it's 
the best way for the language to handle it.

Gabe
_________________________________________________________________
Get the power of Windows + Web with the new Windows Live.
http://www.windowslive.com?ocid=TXT_TAGHM_Wave2_powerofwindows_122007
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to