Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I always use service, or can I use the repositories directly?

Should I always go through the services when I try to follow DDD?

Or can I use a repository directly to get a domain object?

like image 704
jgauffin Avatar asked Jan 20 '12 15:01

jgauffin


1 Answers

Personally, I don't like seeing repositories in controllers, or in the presentation layer in general. But I've seen it many times and there's nothing wrong with it in the context of DDD.

I think the answer is that it depends on how big your project is. A service layer is more often found in more complex projects. Whereas simpler MVC websites for example just use repositories directly.

like image 87
autonomatt Avatar answered Oct 13 '22 22:10

autonomatt