DEV Community

loading...

Discussion on: Introducing Gate Classes (Design Pattern)

jamesmh profile image
James Hickey Author

Usually, I have a project structure like:

web (app layer) -> use cases -> domain project

I tend to put all these kinds of classes in the use cases project. I'll have a structure using feature folders something like:

  • Features
    • Orders
    • Payments
    • Shipping

For cross-cutting stuff like checking a user's role, etc. I would create another folder in the root of the use case projects called "Gates".

If a specific gate class is really tied to a specific feature of the application, which is rare since they are mostly useful for cross-cutting kinds of concerns like checking user permissions etc., then I would just make a "Gates" folder in the features folder:

  • Orders
    • Gates (folder)
    • PlaceStandardOrderCommand.cs (use case)
    • GetActiveOrderForUserQuery.cs (use case)
    • ...and more use cases...