Skip to content

Commit

Permalink
GitBook: [master] 5 pages modified
Browse files Browse the repository at this point in the history
  • Loading branch information
mynkow authored and gitbook-bot committed Oct 1, 2020
1 parent 44c6c8f commit 7ec74ba
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

## Cronus Framework

* [Concepts](cronus-framework/concepts/README.md)
* [DDD](cronus-framework/concepts/ddd.md)
* [CQRS](cronus-framework/concepts/cqrs.md)
* [Domain Modeling](cronus-framework/domain-modeling/README.md)
* [Aggregate](cronus-framework/domain-modeling/aggregate.md)
* [Entity](cronus-framework/domain-modeling/entity.md)
Expand Down
2 changes: 2 additions & 0 deletions docs/cronus-framework/concepts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Concepts

2 changes: 2 additions & 0 deletions docs/cronus-framework/concepts/cqrs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# CQRS

2 changes: 2 additions & 0 deletions docs/cronus-framework/concepts/ddd.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# DDD

51 changes: 51 additions & 0 deletions docs/message-handlers/application-services.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,53 @@
# Application Services

This is a handler where commands are received and delivered to the addressed AggregateRoot. We call these handlers _ApplicationService_. This is the _write side_ in CQRS.

## Communication Guide Table

| Triggered by | Description |
| :--- | :--- |
| Command | A command is used to dispatch domain model changes. It can either be accepted or rejected depending on the domain model invariants |

## Best Practices

{% hint style="success" %}
**You can/should/must...**

* an appservice **can** load an aggregate root from the event store
* an appservice **can** save new aggregate root events to the event store
* an appservice **can** establish calls to the ReadModel \(not common practice but sometimes needed\)
* an appservice **can** establish calls to external services
* you **can** do dependency orchestration
* an appservice **must** be stateless
* an appservice **must** update only one aggregate root. Yes, this means that you can create one aggregate and update another one but think twice
{% endhint %}

{% hint style="warning" %}
**You should not...**

* an appservice **should not** update more than one aggregate root in single command/handler
* you **should not** place domain logic inside an application service
* you **should not** use application service to send emails, push notifications etc. Use Port or Gateway instead
* an appservice **should not** update the ReadModel
{% endhint %}

## Examples

```csharp
public class AccountAppService : AggregateRootApplicationService<Account>,
ICommandHandler<RegisterAccount>,
ICommandHandler<ActivateAccount>,
ICommandHandler<SuspendAccount>,
ICommandHandler<ResetAccountPassword>,
ICommandHandler<ChangeAccountEmail>,
ICommandHandler<ChangeAccountUsername>
{
public void Handle(SuspendAccount message)
{
Update(message.Id, account => account.Suspend());
}

...
}
```

0 comments on commit 7ec74ba

Please sign in to comment.