IMPROVEMENT REQUEST - JCache and whole of joomla?

User avatar
e-motiv
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 168
Joined: Sun May 06, 2007 12:33 pm
Contact:

IMPROVEMENT REQUEST - JCache and whole of joomla?

Postby e-motiv » Sun Nov 15, 2009 1:23 pm

I saw the following code in 1.5 and 1.6 (trunk) for the JCache object and I thought it could be improved. Old code:

Code: Select all

function __construct($options)
    {
        $this->_options = &$options;

        // Get the default group and caching
        if (isset($options['language'])) {
            $this->_options['language'] = $options['language'];
        } else {
            $options['language'] = 'en-GB';
        }

        if (isset($options['cachebase'])) {
            $this->_options['cachebase'] = $options['cachebase'];
        } else {
            $this->_options['cachebase'] = JPATH_ROOT.DS.'cache';
        }

        if (isset($options['defaultgroup'])) {
            $this->_options['defaultgroup'] = $options['defaultgroup'];
        } else {
            $this->_options['defaultgroup'] = 'default';
        }

        if (isset($options['caching'])) {
            $this->_options['caching'] =  $options['caching'];
        } else {
            $this->_options['caching'] = true;
        }

        if (isset($options['storage'])) {
            $this->_options['storage'] = $options['storage'];
        } else {
            $this->_options['storage'] = 'file';
        }

        //Fix to detect if template positions are enabled...
        if (JRequest::getCMD('tpl',0)) {
            $this->_options['caching'] = false;
        }
    }
 
New code:

Code: Select all

function __construct($options)
    {
        $this->_options = array(
            'language'=>'en-GB',
            'cachebase'=>JPATH_ROOT.DS.'cache',
            'defaultgroup'=>'default',
            'caching'=>true,
            'storage'=>'file');

        //Overwrite default options with given options
        $this->_options = array_merge($this->_options,$options); 
//or with the ampersand "...& $options);" for speed if array_merge or this construct would make a deep copy otherwise

        //Fix to detect if template positions are enabled...
        if (JRequest::getCMD('tpl',0)) {
            $this->_options['caching'] = false;
        }
    } 
Why?
  1. It generates far less php code.
  2. It is much faster.
  3. It allows quick and easy addition of future parameteres to developers
Further possible improvements
I also propose...
  1. ..to use this technique wherever this kind of constructor occurs in the joomla library (with array that sets options or similar).
  2. ..to make a function in JObject (e.g. setOptions(..)) to handle this (for even more improvement)
  3. ..to alter a lot of other joomla library objects to be written as thus (in stead of the old method e.g. function something(opt1, opt2, opt3))(and even more :eek:)
This way, this technique would not only improve one object (JCache) with small improvements, but an immense lot of possible objects with a relatively noticeable improvement in the whole of Joomla.

What do you thinks guys?

http://www.e-motiv.net Professional web development <== e-motiv ==> Spin off web projects http://attic.e-motiv.net

User avatar
Hackwar
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3762
Joined: Fri Sep 16, 2005 8:41 pm
Location: NRW - Germany
Contact:

Re: IMPROVEMENT REQUEST - JCache and whole of joomla?

Postby Hackwar » Sun Nov 15, 2009 4:02 pm

Hi e-builds,
this sounds good. Can you post this to the Joomla development CMS mailinglist? This would not be something that we would add to 1.5, but if you would provide a patch for 1.6, we could take a serious look at implementing this.

Hannes

User avatar
e-motiv
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 168
Joined: Sun May 06, 2007 12:33 pm
Contact:

Re: IMPROVEMENT REQUEST - JCache and whole of joomla?

Postby e-motiv » Mon Nov 16, 2009 11:05 pm

Patch submitted:http://groups.google.com/group/joomla-dev-cms/browse_thread/thread/41c5a90404361045

More opinions and thoughts needed about "Further possible improvements" above.

http://www.e-motiv.net Professional web development <== e-motiv ==> Spin off web projects http://attic.e-motiv.net

User avatar
e-motiv
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 168
Joined: Sun May 06, 2007 12:33 pm
Contact:

Re: IMPROVEMENT REQUEST - JCache and whole of joomla?

Postby e-motiv » Mon Dec 21, 2009 11:32 am

Why is no-one answering to that post on the mailinglist?
Is this normal (wait time) or did I do something the wrong way?

http://www.e-motiv.net Professional web development <== e-motiv ==> Spin off web projects http://attic.e-motiv.net

User avatar
darb
Joomla! Ace
Joomla! Ace
Posts: 1275
Joined: Thu Jul 06, 2006 12:57 pm
Location: Stockholm Sweden
Contact:

Re: IMPROVEMENT REQUEST - JCache and whole of joomla?

Postby darb » Thu Dec 31, 2009 9:05 am

Well hope you get some attention really for this Joomla improvement even it have been Christmas and holidays.

It will be interesting to see how it work now with a better integration of new submitted improvements from the community.

Feedback anyone ?


So who evaluate, decide and take care of this patch?

Happy New Joomla Year!
Success in the long run Its not about the code its about the people and community that's make it!
Its not what you say its what you do that matters!

Darb - aka ssnobben


Return to “Feature Requests - White Papers - Archived”

Who is online

Users browsing this forum: No registered users and 1 guest