Depending on the application i may use context object. I think request object is silly if all your doing is $this->_post = $_POST;
Here is an example of a context object more further down this comment
PHP Code:
#/calendar/day/year/month/day#/
$viewhelper = new CalendarViewHelper();
$viewhelper->setDayMonthYear( array($year, $month, $day) );
$viewhelper->setUserName( SystemConfig::$SubdomainBrowsing );
$viewhelper->setViewSize('large');
$calendar = new CalendarDay(new GregorianCalculations());
$body.=$calendar->build($viewhelper);
all chains, decorators, composites, CoR will use a
viewhelper/context object/visitor - see my next example:
I agree. PHP has one of the programming world's most versatile implementations of array, and that should be used whenever there is just data involved, with no behavior.
I would also add:
and not holding configuration information.
Problem that arises if config is in array:
Some applications use an array which are passed to the constructor as to provide another type of functionality. That is bad design because the object is holding to much responsibility. It needs to be broken up into all the options you want.
I think i've seen this in some pear packages also. Cache_Lite i think. This is a way to avoid it.
PHP Code:
$chain = Cache_Database($handle, Cache_FileSystem('directory', Cache_Memory()));
//if object
$chain->saveObject($contextObject);
//if non object
$chain->save($contextObject);
pick and choose by changing the chain. and its a lot easier to maintain as responsiblities are spread correctly. This caching solution is something i just started building... so its not a full implementation of the api yet.
PHP will always continue to keep arrays aka collections/dictionaries alive.
However php will mold into an oop language. php5 was a big step and i'm sure it won't stop there.
Just pointing out that PHP and Java are two very different beasts and just because they have similarities in syntax, doesn't mean they should be programmed in the same way.
this was properly answered by:
I think the problem that you have highlighted is more down to the lack of experience in both design and object oriented methodologies.
Most often php developers have experience with other oo languages. In my case c# to help in areas php can't ... windows forms. [yes i already know about php-gtk ]
Bookmarks