[PEPr] Comment on Caching::phpfastcache

"Bertrand Mansion" <[email protected]>
Newsgroups gmane.comp.php.pear.devel
Message-ID <[email protected]>
Hi,



I only looked quickly at the code.



I think that there is room for improvements. The 'one class does it all'
concept is bad here because it reduces your code reusability,
extendability, flexibility and creates maintenance problems. It makes it
painful to add a new backend (redis, apcu, tokyotyrant, mongodb, ...) or
modify an existing one.



You could improve it by looking at the current Cache_Lite or Cache
packages, and investigating design patterns like Bridge and maybe Chain of
responsability in case you want to keep the possibility to have multiple
backends.



http://en.wikipedia.org/wiki/Bridge_pattern

http://en.wikipedia.org/wiki/Chain_of_responsibility_pattern



You could allow backends to register themselves as available upon loading.
You seem to have defined your own order of priority for backends, this
should maybe left as a parameter for the user.



You use static functions for set/get. This is also wrong because it doesn't
allow to have more than one cache. You should provide a factory method
instead, maybe a singleton method if necessary. See the Log package, it is
a good example of an API you could use.



In conclusion, your code probably works fine, but it is poor design.

-- 
http://pear.php.net/pepr/pepr-proposal-show.php?id=692

-- 
PEAR Development Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.