Coding style question; function calling
Posted: Fri May 27, 2011 1:16 am
When I have a function called in a hook which needs config items is it better to do this:
or this
or this (which is almost like #1)
Code: Select all
switch($event) {
case 'somehook':
$foocfg = $this->get_config('foo');
$barcfg = $this->get_config('bar');
$foo = doWork($foocfg, $barcfg);
...
...
break;
...
...
function doWork($foocfg, $barcfg) {
....
....
return($thingy);
}
Code: Select all
switch($event) {
case 'somehook':
$foo = doWork();
...
...
break;
...
...
function doWork() {
global serendipity;
$foocfg = $this->get_config('foo');
$barcfg = $this->get_config('bar');
....
....
return($thingy);
}
or this (which is almost like #1)
Code: Select all
switch($event) {
case 'somehook':
$foo = doWork($this->get_config('foo'), $this->get_config('bar'));
...
...
break;
...
...
function doWork($foocfg,$barcfg) {
global serendipity;
....
....
return($thingy);
}