Why use service layer?

前端 未结 3 428
忘掉有多难
忘掉有多难 2020-12-01 00:13

I looked at the example on http://solitarygeek.com/java/developing-a-simple-java-application-with-spring/comment-page-1#comment-1639

I\'m trying to figure out why t

3条回答
  •  借酒劲吻你
    2020-12-01 00:55

    Take a look at the following article:

    http://www.martinfowler.com/bliki/AnemicDomainModel.html

    It all depends on where you want to put your logic - in your services or your domain objects.

    The service layer approach is appropriate if you have a complex architecture and require different interfaces to your DAO's and data. It's also good to provide course grained methods for clients to call - which call out to multiple DAO's to get data.

    However, in most cases what you want is a simple architecture so skip the service layer and look at a domain model approach. Domain Driven Design by Eric Evans and the InfoQ article here expand on this:

    http://www.infoq.com/articles/ffffd-in-practice

提交回复
热议问题