Quote Originally Posted by Dr Livingston
This part still could be refactored as SWITCH is a bad code smell
You might be able to get off with something like this:

PHP Code:
class FrontController
{

    var 
$commands = array(
        
'add'  => 'UserAddCommand',
        
'edit' => 'UserEditCommand',
        
'list' => 'UserListCommand'
    
);
    
    function 
run($page)
    {
        
$command = new $this->commands[$page];
        
$command->execute();

        
$view $command->getView();
        
$view->render();
    }


The bad smell for me was the repitition of "$command = ...; break;". Much better to replace that with a simple "return" imo. ("$this->" is also very ugly imo, and is the thing I like the least about PHP.)

I get the feeling that there is lots of over-engeneering going on, when simpler solutions would work. Look at the number of Java projects out there at the moment going under the "better than J2EE" banner. (It is interesting watching the arguments between the hardcore Java croud and the Rails people!)

I'd much rather do these things like this:
http://www.sitepoint.com/forums/show...97&postcount=9

Happy coding peiople,
Douglas