On Thu, 2003-07-17 at 21:10, Ow Mun Heng wrote:
> > '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.
> 
> The $GLOBALS['parameter'] is actually defined in ONE(a config file that
> houses all the parameters and another a language file) place where it can be
> changed. So, i would say that's an argument list, is it not?

No, it's a configuration file. An argument list is the bit between the 
parentheses when you write a function call:

   $retval = some_func($this, $is, $the, $argument, $list);

If your config file had all of those variables in an array or something,
and you passed that array to your function, *that* would be an argument
list.

See below:

config.php:
<?php
$config = array('logout' => 1,
                'overall_summary' => 'Here is the summary',
                etc....);
?>

script.php:
<?php
include('config.php');
display_menu_html($config);
?>

Problem solved. The only thing left which can conflict is the name
$config, and you could solve that by calling it something you're sure
nobody else will be using (maybe $_omh_config or something). Now, you
can lift your config file and display_menu_html() function and drop
them into pretty much any script and be much more sure that you won't
have to crawl through all the code making sure there are no variable
name conflicts.

> The other way would be to write a function that obtains that from the
> argument list. But as I see it, it's basically the same thing? NO?

No, because say you want to use this function in another script. First
you need to make sure that this new script isn't already using any
globals with any of the names you want to use--otherwise, you'll have
variable clashes--where you expect one thing to be in $logout, for
instance, but the script is using the name $logout for something else,
and the value isn't what you expect. 

> Class.. That's not somewhere I would want to venture, not right now anyway.
> Just starting out.
> 
> Cheers,
> Mun Heng, Ow
> H/M Engineering
> Western Digital M'sia 
> DID : 03-7870 5168

There was a discussion on this list about programming practices and 
books about programming--I think last week or the week before. Try a
search on the archives. Anyway, there are lot of great books on
programming which should help--and excellent and easy-to-read book which
covers a lot of things which you *don't* want to have to figure out
yourself is 'Code Complete', by Steve McConnell.


-- 
 Torben Wilson <[EMAIL PROTECTED]>                        +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 ====-----




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to