Hi,

I am building a small cake application to learn MVC and cakePHP.
I have a question about where to put business logic, I have read that
controls should be skinny and models should be fat. Eg the business
rules should live in the models.

In my application I have the following models User, Portfolio,
Currency.
A user has 1 portfolio which has 1 currency. When I register a user I
would like to create their portfolio and assign it the default
currency.

My question is where to do the creation of the portfolio?
(Fat Controller)
1. Call the User model to create a new user.
2. Call the Currency model to get the default currency.
3. Call the Portfolio model to create a new portfolio for the new user
with the default currency.

Or

(Fat Model)
1. The controller calls a custom function on the Users model. Eg
registerUser($formData)
2. The User model validates and saves the new user.
3. The user model then calls the Portfolio model to create a new
portfolio for the new user.
4. The Portfolio model calls the Currency model to get the default
currency and creates the new portfolio for the new user.

The advantage I can see to the Fat Model way is that the logic for
registering a new user is all in one spot.
So if I have many controllers that need to register a new user I can
just use the same code.

Is this on the right track?

Thanks,
Alex

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to