6
4
If a controller gets too fat and model instantiation starts to add up, a service layer could be used.
If I just wrap the logic inside a service class, I will get a bunch of Services with one/two methods. This feels like a code smell. Any best practices regarding this?
Can a service instantiate models?
If a service instantiates models, the services can't be unit tested. They can only be covered by integration tests?
1
I would be careful using an auto mapper here http://www.uglybugger.org/software/post/friends_dont_let_friends_use_automapper
– Daniel Little – 2014-09-24T01:05:29.807AutoMapper comes with a built-in unit testing functionality which allows you to verify all your mapping routines with one line. Author of this post did not mention that. – CodeART – 2014-10-22T15:54:31.953
But he does know about it, and has used it. The comments go into this a bit. – Daniel Little – 2014-10-23T00:20:09.173
Lots of classes with only one or two methods usually means they are not cohesive. A service layer, if it exists, should be thin with the bulk of the logic being in the models. It seems rather pointless to bind a view to a dumb object which is nothing more than a property bag. The model in MVC should be the rich domain model, not an anemic one http://www.martinfowler.com/bliki/AnemicDomainModel.html
– Andy – 2014-11-10T01:18:11.060