diff --git a/docs/cqrs/command/index.md b/docs/cqrs/command/index.md index 1fce18c32..92b3de812 100644 --- a/docs/cqrs/command/index.md +++ b/docs/cqrs/command/index.md @@ -69,6 +69,10 @@ As you can see, the command handler is really simple - it just finds project wit 6. Do not throw exceptions from inside commands. The client will receive generic error (`500 Internal Server Error`). Do it only as a last resort. 7. Database transaction will be commited at the end of the [pipeline] (assuming [CommitTransaction] pipeline element was added), so it's not recommended to commit it inside query handler as it may make serialized [events] inconsistent with the entity. +## Naming conventions + +Commands in CQRS are responsible for modifying the state of the system, and therefore their names should reflect the action they trigger. A common convention is to use imperative verbs that clearly describe the intent, such as `UpdateProjectName`, `DeleteProject`, or `AssignEmployeeToAssignment`. Handlers should share the identical name as the associated contract, appended with the `CH` suffix. This practice enhances ease of identification and ensures a straightforward correlation between contracts and their corresponding handlers. + [aggregates]: ../../domain/aggregate/index.md [events]: ../../domain/domain_event/index.md [pipeline]: ../pipeline/index.md diff --git a/docs/cqrs/operation/index.md b/docs/cqrs/operation/index.md index d8eb195b3..7d15c023c 100644 --- a/docs/cqrs/operation/index.md +++ b/docs/cqrs/operation/index.md @@ -57,3 +57,7 @@ public class PayForAccessOH : IOperationHandler } } ``` + +## Naming conventions + +Operations are designed to both modify the state of the system and provide a result. To uphold a consistent naming convention, these operations should be named to reflect both their transformative action and if possible the nature of the information returned. Striking a balance between clarity and conciseness, names like `GenerateReferralLink`, `GetNextQuestion`, or `AnswerQuestion` convey both the intent of state modification and the potential for a consequential result. Correspondingly, handlers for operations should start with the name of the associated operation while incorporating the `OH` suffix. diff --git a/docs/cqrs/query/index.md b/docs/cqrs/query/index.md index 5faa94fc6..208620d97 100644 --- a/docs/cqrs/query/index.md +++ b/docs/cqrs/query/index.md @@ -60,4 +60,8 @@ public class ProjectsQH : IQueryHandler> } ``` +## Naming conventions + +Queries are designed to retrieve information without altering the system's state. To maintain a clear and consistent naming convention, queries should possess names that directly indicate the type of information being requested. An effective approach is to use descriptive nouns or noun phrases, exemplified by names like `Projects`, `ProjectById`, or `EmployeesInAssignment`. Query handlers should be named in alignment with the associated query, appending the `QH` suffix. + [validation]: ../validation/index.md