[Solar-talk] Method-Based Actions

Travis Swicegood development at domain51.com
Sat Jun 24 11:21:31 PDT 2006


Paul M Jones wrote:
> I just realized this whole conversation might be moot.   
> Solar_Controller_Page::_actionMethod() takes an action and returns a  
> method name; it can be overridden in subclasses.
>
> Thus, Travis_Controller_Page::_actionMethod() can convert $action to  
> anything it likes and return that.  Is that helpful at all?
>   

Yup - does exactly what I'm talking about.  The only difference is I 
would move it to another class as I'm not a fan private/protected 
methods.  That's based on my TDD sensibilities.  Anything that's 
private/protected can't be directly tested, but instead has to be tested 
by assumption.  Example: editAction() can only be called if whatever 
relies on _actionMethod() gets the proper return from _actionMethod() 
instead of testing MethodMapper to determine that it returns like you 
expect, then having _actionMethod() setup an instance of a tested class 
and use it in the way you've already tested).

I consider private/protected methods an anti-pattern, but I'd bet I'm in 
the minority on that view based on the underwhelming popularity of 
SimpleTest and phpUnit.

-Travis


More information about the solar-talk mailing list