Re: Use of subroutines
From: Ken Plotkin (kplotkin_at_nospam-cox.net)
Date: 02/28/04
- Next message: Ken Plotkin: "Re: Byte counting and newlines"
- Previous message: Duane Bozarth: "Re: Use of subroutines"
- In reply to: Pterostyrax: "Re: Use of subroutines"
- Next in thread: Pterostyrax: "Re: Use of subroutines"
- Reply: Pterostyrax: "Re: Use of subroutines"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 28 Feb 2004 13:29:24 -0500
On 28 Feb 2004 04:16:20 -0800, pterostyrax@yahoo.com (Pterostyrax)
wrote:
[snip]
>GOTOs, I have not misunderstood the problem. Indeed, there is one
>instance of a GOTO in my program that actually aids in following the
>logic in the program, where trying to have 100% modular code would
>have obfuscated an important part of the logic. I used the word
Go tos are not evil. Trying to write a program with no go tos can be
evil - there are times where you just need to jump someplace.
>"indiscriminate" very carefully as this is the essence of the problem,
>as you rightly point out. I was simply trying to point out that the
>"indiscriminate" use of subroutines is essentially the same as the
>"indiscriminate" use of GOTOs that results in code that becomes almost
>incomprehensible and therefore unmaintainable.
Indiscriminate use of anything can be evil. You generally have to
work at it to make too many subroutines into a problem. It's really
easy to make a mess with too many go tos.
[snip]
>I still maintain that a subroutine is first and foremost a GOTO
>statement. In essence, and more importantly in practice, a call to a
>subroutine says "okay, stop right in the middle of what you are doing,
>go to a physically removed place in the code, try to understand logic
>in a new environment with new variable names that may or may not
>correspond to variable names you are previously familiar with
[snip]
Actually, quite the opposite. Calling a subroutine means to do some
predefined operation on stuff you have, and come back with the
results. You don't need to know how it was done. Often you don't
care. All you know is that you asked for something and got it.
Kind of like sending out for a pizza.
IMHO, the proper mindset for writing a subroutine is to think of
isolating tasks, so that once a managable task is subroutinized you're
done, and never have to mess with it again. Nor worry about its
interaction with the program, other than via specifically defined
variables.
Ken Plotkin
- Next message: Ken Plotkin: "Re: Byte counting and newlines"
- Previous message: Duane Bozarth: "Re: Use of subroutines"
- In reply to: Pterostyrax: "Re: Use of subroutines"
- Next in thread: Pterostyrax: "Re: Use of subroutines"
- Reply: Pterostyrax: "Re: Use of subroutines"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|