Introducing Cobra
Chuck Esterbrook
chuck.esterbrook at gmail.com
Wed Jan 2 18:52:53 PST 2008
On Jan 2, 2008 2:57 PM, Gabriel Sechan <gsechan at hotmail.com> wrote:
>
>
> ----------------------------------------
> > Date: Wed, 2 Jan 2008 14:25:17 -0800
> > From: x at xman.org
> > To: kplug-lpsg at kernel-panic.org
> > 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.
>
But I didn't actually experience this problem with Python and I used
to do *a lot* of Python. In other words, I didn't find it hard to
change the indent level of my code as I restructured it.
I guess that's the key for me. People keep raising objections about
indentation-for-blocks that my experience comes back with "not a
problem", "didn't happen" or "maybe once a year".
Since we're doing cute sigs and such:
I-can't-pretend-all-these-bad-things-plagued-me-when-they-didn't-ly-yours,
-Chuck
More information about the KPLUG-LPSG
mailing list