Hacker News new | past | comments | ask | show | jobs | submit login

>But take something like "new users are sent a welcome email." Would you put that in the model?

Yes, 100% absolutely, no question.

>That fits into the class of behavior and belongs in a controller.

The controller is just to handle input, it has nothing to do with behavior. This is one of the key misunderstandings that differentiates between MVC and the weird mess rails calls MVC.




"Controller" is one of those terms that has meant a lot of different things at different times and in different systems. I agree that the same code asset (whether it's called a controller or whatnot) that handles user input should not be responsible for implementing a rule like "new users get emailed." At the same time, I also don't think such a rule belongs in your model layer. It should go in its own class (sometimes called a service, sometimes also called a controller). So the controller-managing-ui calls the controller-defining-behavior to make changes to the model.


>"Controller" is one of those terms that has meant a lot of different things at different times and in different systems

It has a very specific meaning: http://en.wikipedia.org/wiki/Model–view–controller

>At the same time, I also don't think such a rule belongs in your model layer.

I'm not talking personal preference, I am talking how MVC works. If your application were MVC, then yes it absolutely would be in the model.


That's what I thought too, thanks for weighting in.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: