A service is an application component responsible for implementing a use case. It coordinates the work without taking on every responsibility itself. section 4.1.3
Publishing a comment
CommentService implements the publish-comment use case: it delegates storing the comment to a repository and sending an email notification to a proxy. Interfaces keep the service decoupled from those implementations. section 4.1.3
In Spring, @Service marks a component’s responsibility explicitly; Spring creates an instance and adds it to its context. Use @Repository to mark a component responsible for data persistence. section 4.3
Figure 4.6 The CommentService object depends on the abstractions provided by CommentRepository and CommentNotificationProxy interfaces. The classes DBCommentRepository and EmailCommentNotificationProxy further implement these interfaces. This design decouples the implementation of the “publish comment” use case from its dependencies and makes the application easier to change for future developments.

The diagram shows how interfaces let the service depend on abstractions rather than specific implementations. section 4.1.3



