Re: Too much of $GLOBALS[] a problem??
| From: | Lars Torben Wilson | Date: | Fri, 18 Jul 2003 04:05:10 +0000 |
| Subject: | Re: Too much of $GLOBALS[] a problem?? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-155718@lists.php.net to get a copy of this message | ||
On Thu, 2003-07-17 at 18:35, Ow Mun Heng wrote:
> Hi All,
>
> Just a quick question on this. In my scripts, I'm using A LOT Of
> $GLOBALS['my_parameter'] to get the declared values/string. 1 example below
> :
The only real problem is if you ever want to use that code in anything
else. Using lots of globals will make that harder, since it will mean
that you cannot simply lift that function out and drop it into some
other chunk of code without making sure that the new global space
contains all those globals, and that they contain what you expect.
This is called 'tightly-coupled' code. It's just harder to reuse.
'Loosely-coupled' code relied much less on the environment around it.
It would typically receive its values through an argument list, array
of values it needs, or perhaps by being a method in a class which has
attribute values for all of the necessary stuff.
Other than that, it's not a huge issue.
--
Torben Wilson <torben@php.net> +1.604.709.0506
http://www.thebuttlesschaps.com http://www.inflatableeye.com
http://www.hybrid17.com http://www.themainonmain.com
-----==== Boycott Starbucks! http://www.haidabuckscafe.com ====-----