MVC best practice when adding functions to controller?
Posted
by Patrick
on Stack Overflow
See other posts from Stack Overflow
or by Patrick
Published on 2010-04-09T15:06:14Z
Indexed on
2010/04/09
15:13 UTC
Read the original article
Hit count: 213
mvc
Hi
I'm writing a function in my controller; this is supposed to take in a form, process it, register the user in DB, send a confirmation email etc etc.
to avoid this function to be too cluttered, I was thinking of calling some sub-functions (eg:
function registration()
{
//process form..
_insertInDb($formdata)
_send_mail($address);
//load confirmation view..
}
function _send_mail($to)
{
//code here
}
function _insertInDb($formdata)
{
//other code here...
}
I'm not sure whether writing all the functions in the controller would be best practice -maybe I should insert all 'supporting' function (eg send_mail and insertInDb in this example) in another file and then import them?
This would probably make the controller much more readable.. what's your view?
© Stack Overflow or respective owner