in reply to What is the purpose of subroutine parameters?
The first question is "Why do we use subroutines?"
The answer to that is twofold, both relating to putting a code snippet that's used more than once in one place.
This has to do with a few core programming concepts, all of them related. The basic idea is that you want a piece of code to do what it does, without as litle relationship to the rest of the code in your program. Ideally, what you can do is to take a subroutine out of one program and just "plug it in" to another program, knowing exactly how it's going to work. And, more importantly, knowing that it will not affect any other part of your program. This allows you to have confidence in your program.
Passing variables in means that you can stop using global variables. If you're curious as to why globals are (almost always) bad, ask and a bunch of people would be glad to help you understand. :)
------
We are the carpenters and bricklayers of the Information Age.
Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: What is the purpose of subroutine parameters?
by Anonymous Monk on Sep 17, 2001 at 17:35 UTC |