From eb2a67986881160d24f097fc113e8c52692fa9b6 Mon Sep 17 00:00:00 2001 From: Lars Simon Winzer Date: Wed, 8 Apr 2026 18:18:17 +0200 Subject: [PATCH] Docs: Modify guide on implementing a command by mentioning pre-execution checks --- .../networking/commands/guide-on-implementing-a-command.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/documents/docs/networking/commands/guide-on-implementing-a-command.md b/documents/docs/networking/commands/guide-on-implementing-a-command.md index 037251f..e45b6fd 100644 --- a/documents/docs/networking/commands/guide-on-implementing-a-command.md +++ b/documents/docs/networking/commands/guide-on-implementing-a-command.md @@ -159,6 +159,9 @@ public class GreetHandler implements CommandHandler { **Rules for the Handler class:** - Declare all dependencies as `private final` fields, injected through the constructor. +- Use `addCheck(...)` to attach pre-execution checks that should run before `execute(...)`. +- If several handlers share the same trivial logic, such as verifying that the user is logged in, + extract that logic into a separate `HandlerCheck` and reuse it instead of duplicating the code. - Always dispatch exactly one response per execution path. Every branch must end with a `responseDispatcher.dispatch(...)` call. - Use `ErrorResponse` for domain-level failures (e.g. entity not found, precondition not met).