[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: OT: Why is C so popular?

On Thu, 28 Aug 2003 17:29:52 -0500
Alan Shutko <ats@acm.org> wrote:
> I've never understood people who are religious about that.  It's the
> same amount of effort whether you do it when you first write the if,
> or when you add something to it (ie, minimal).  The only difference I
> see is that if you _don't_ later add something to the if, you've
> wasted that effort.

    It's called maintainability.  Who says *you* are going to be the next
person to touch the code?  By sticking to structures that are expandable down
the road you avoid two things and improve a third.

1: Avoid unneeded effort to reform the code to do what needs to be done.
2: Avoid the possibility of a bug.
3: Make the code far more readable.

   Hey a few years back when I was starting to learn Perl I thought TIMTWOWTDI
was peachie keen.  That's until I had to maintain Perl scripts, more often
than not my own.  This is nice when you first get into the language:
if foo {bar}
unless foo {bar}
bar if foo
bar unless foo

    Nice that is, until 6 months down the line when you're pawing through code
trying to figure out what's going on and hit an if followed by an unless and
one of them contains the reverse of block before condition.  Now your brain,
instead of being able to read and process 1 construct in three different forms
is dealing with 3 constructs.  I've come to appreciate the fact that if it is
a conditional it is going to be in this format:
if cond:
elif cond:

    And no other.  I don't need to worry about my brain trying to wrap itself
around 4 different forms which are contrary to one another.  This is a good

         Steve C. Lamb         | I'm your priest, I'm your shrink, I'm your
       PGP Key: 8B6E99C5       | main connection to the switchboard of souls.

Attachment: pgplSISQ51Tnm.pgp
Description: PGP signature

Reply to: