oop - MVC - Is It Wrong To Redirect From Model -


i ask whether it's approach redirect within model instead of controller.

the reason want because easier unit test redirection model (i pass mock redirector object model in tests) opposed controller more difficult unit test. keeps controller thinner in controller create instance of model , pass parameters request object. there not single if/else in controller way.

is bad practise?

neither controller nor model should redirecting anywhere. http location header form of response, strictly in purview of views.

model layer deals business logic, should oblivious existence of presentation layer.

basically, goes down this: controllers handle input, views handle output. http headers part of output.

note: when dealing rails clones, common see redirects performed in "controller". because call "controller" merger of view , controller responsibilities. side-effect of opting replace real views simple templates 3rd side of triad.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -