Greetings all,
Been working in Framework for a while and I've taught the
Framework course 1 or 2 times and while I enjoy using Framework there is one
thing that slows me down. That is, often configuration options are set
using associative arrays. That, in and of itself, is no problem. But the
problem I've run into is that usually you have to go into the Framework code
itself to find out what the keys for the config arrays need to be. If I
know what the option name is that I want to use it's not that big of a deal,
but there's no way that me, average Framework developer, can memorize all of
the configuration options for all of the classes. To make that easier it
would be nice to have class constants provided for configuration options.
That way an IDE's code completion could be used to help developers specify
which options they want to set without breaking any current code, plus using
phpDoc we could document each option individually rather than in a big block
for $this->_options. For example, in Zend_Cache_Core we currently have:
class Zend_Cache_Core
{
protected $_options = array(
'write_control' => true,
'caching' => true,
'automatic_serialization' => false,
'automatic_cleaning_factor' => 10,
'lifetime' => 3600,
'logging' => false,
'logger' => null,
'ignore_user_abort' => false
);
}
Would have this added
class Zend_Cache_Core
{
/**
* Sets the lifetime of the cache
*/
const CONFIG_LIFETIME = 'lifetime';
const CONFIG_CACHING = 'caching;
const CONFIG_LOGGING = 'logging';
protected $_options = array(
'write_control' => true,
'caching' => true,
'automatic_serialization' => false,
'automatic_cleaning_factor' => 10,
'lifetime' => 3600,
'logging' => false,
'logger' => null,
'ignore_user_abort' => false
);
}
Then to specify the options you would do
$options = array(
Zend_Cache_Core::CONFIG_LIFETIME => 60
);
$cache = Zend_Cache::factory('File', 'Page', $options);
That way developers wouldn't have to browse the Framework code to see what
all the config options are. Instead, code completion would help them find
the right setting.
What do y'all think? It helps us document things better and it also makes
life a lot easier for the developer.
<http://www.zend.com>
<http://www.zend.com/> <http://www.zend.com>
Kevin Schroeder
Technical Consultant
Zend Technologies, Ltd.
<http://www.zend.com> www.zend.com
<<image001.gif>>
