To convert the current structure that Monaco currently has about Commands/Validators and Queries folders to one where each Command and Query are placed in the same file with their corresponding handlers.
This is oriented to decompress the bloating that sometimes might affect the Commands/Queries Handlers files when there are too many commmands/queries for an entity.
Context
In order to better group together queries with their handlers and commands with their respective validators and handlers, it could be better to group each of them together in a single file, to further simplify the navigation between a query and its handler, the same as with a command with its respective validator and handler.
This should make it simpler to navigate through the structure, would align to the vertical slicing more properly, simplify handlers files that sometimes get too bloated when there are too many commands/queries, and would also simplify the testing, aligning it, as well, to the vertical slicing concept as all the tests related to a same slice would be easier to group themselves instead of having a big handlers test class that will contain all tests for all the handlers of a same entity as we currently have.
A con to this approach is that some of the shared code between some slices won't be contained in the same handlers class, within reach of all the different handlers (same would occur with the tests); but I think the solution for this can be as easy to create more extensions and static classes/methods in an "Extensions" folder to contain all the shared code there.
Possible Implementation
To use it as an example, the current folder from Application.Features.Company could be structured like this:
Companies (folder)
Extensions (folder)
[ Any extra extension classes/files that can be used for sharing code between slices ]
CreateCompany.cs
CreateCompany (class)
Command (nested class)
Validator (nested class)
Handler (nested class)
EditCompany.cs
EditCompany (class)
Command (nested class)
Validator (nested class)
Handler (nested class)
DeleteCompany.cs
DeleteCompany (class)
Command (nested class)
Validator (nested class)
Handler (nested class)
GetCompaniesPage.cs
GetCompaniesPage (class)
Query (nested class)
Handler (nested class)
GetCompanyById
GetCompanyById (class)
Query (nested class)
Handler (nested class)
Each of the features (Create/Edit/Delete Company and Get Page/ById) would be separated into different files with a class that will nest 3/2 other classes (depending on whether it's a command or query), and each of these nested classes would be the specific command/query, its handler and (in the case of the commands) its validator.
Detailed Description
To convert the current structure that Monaco currently has about Commands/Validators and Queries folders to one where each Command and Query are placed in the same file with their corresponding handlers. This is oriented to decompress the bloating that sometimes might affect the Commands/Queries Handlers files when there are too many commmands/queries for an entity.
Context
In order to better group together queries with their handlers and commands with their respective validators and handlers, it could be better to group each of them together in a single file, to further simplify the navigation between a query and its handler, the same as with a command with its respective validator and handler. This should make it simpler to navigate through the structure, would align to the vertical slicing more properly, simplify handlers files that sometimes get too bloated when there are too many commands/queries, and would also simplify the testing, aligning it, as well, to the vertical slicing concept as all the tests related to a same slice would be easier to group themselves instead of having a big handlers test class that will contain all tests for all the handlers of a same entity as we currently have. A con to this approach is that some of the shared code between some slices won't be contained in the same handlers class, within reach of all the different handlers (same would occur with the tests); but I think the solution for this can be as easy to create more extensions and static classes/methods in an "Extensions" folder to contain all the shared code there.
Possible Implementation
To use it as an example, the current folder from
Application.Features.Company
could be structured like this:CreateCompany
(class)Command
(nested class)Validator
(nested class)Handler
(nested class)EditCompany
(class)Command
(nested class)Validator
(nested class)Handler
(nested class)DeleteCompany
(class)Command
(nested class)Validator
(nested class)Handler
(nested class)GetCompaniesPage
(class)Query
(nested class)Handler
(nested class)GetCompanyById
(class)Query
(nested class)Handler
(nested class)Each of the features (
Create
/Edit
/Delete
Company andGet Page
/ById
) would be separated into different files with a class that will nest 3/2 other classes (depending on whether it's a command or query), and each of these nested classes would be the specific command/query, its handler and (in the case of the commands) its validator.