Skip to content

Instantly share code, notes, and snippets.

@jacegu
Last active August 3, 2021 03:20
Show Gist options
  • Save jacegu/6091719 to your computer and use it in GitHub Desktop.
Save jacegu/6091719 to your computer and use it in GitHub Desktop.
Differences between Domain Services & Application Services

The differences between a domain service and an application services are subtle but critical:

  • Domain services are very granular where as application services are a facade purposed with providing an API.
  • Domain services contain domain logic that can’t naturally be placed in an entity or value object whereas application services orchestrate the execution of domain logic and don’t themselves implement any domain logic.
  • Domain service methods can have other domain elements as operands and return values whereas application services operate upon trivial operands such as identity values and primitive data structures.
  • Application services declare dependencies on infrastructural services required to execute domain logic.
  • Command handlers are a flavor of application services which focus on handling a single command typically in a CQRS architecture.

Source: http://gorodinski.com/blog/2012/04/14/services-in-domain-driven-design-ddd/

@gpg0
Copy link

gpg0 commented Jul 26, 2013

More ideas:

  • The Application Services are the direct clients of the domain model.
  • Application Services generally provide security and transaction management, and acting as Facade to the model.
  • They are task managers, transforming use case flow requests into the execution of domain logic.
  • When using an ACID database, the Application Services control transactions, ensuring that model state transitions are atomically persisted.
  • We should strive to push all business domain logic into the domain model, whether that be in Aggregates, Value Objects, or Domain Services.
  • Keep Application Services thin, using them only to coordinate tasks on the model.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment