I am a Developer Advocate for Security in Mobile Apps and APIs at approov.io.
Another passion is the Elixir programming language that was designed to be concurrent, distributed and fault tolerant.
Location
Scotland
Education
Self teached Developer
Work
Developer Advocate for Mobile and API Security at approov.io
Hi James, thanks for this good article in explain why we should avoid the CRUD trap ;)
When coding I prefer to be explicit over implicit once I also prefer to use the domain level language to define each action for the resource being requested.
I split my folders structure as resource/action, so for route account/{id}/debit I would end up with a controller in src/Resources/Accounts/Debit/AccountsDebitController.extension...
This is what I call the Resource Design Pattern, that allows us to achieve more easily SOLID and Clean Code and at same time acts as documentation for the project.
Once the folder structure reflects all actions available for each resource this will be the type of documentation that never goes out of sync with the project, therefore never lies ;).
Senior software developer at Amazon Web Services. I work on the AWS Serverless Application Repository and AWS SAM. Iām passionate about writing quality software and teaching others how to do the same.
Location
Seattle, WA
Education
BS Computer Engineering, Minors: CS and Math
Work
Sr. Software Development Engineer at Amazon Web Services
Cool. That's a nice structure. I'm generally using JAX-RS so I create a controller for the overall entity type, then have a method for each action. This works ok because my domain logic is delegated to a separate layer so the REST controller is generally just translating between the REST protocol and the domain logic's interfaces. However if I did one controller per action, your directory structure would work well.
I am a Developer Advocate for Security in Mobile Apps and APIs at approov.io.
Another passion is the Elixir programming language that was designed to be concurrent, distributed and fault tolerant.
Location
Scotland
Education
Self teached Developer
Work
Developer Advocate for Mobile and API Security at approov.io
My Controller don't have any logic related with the Domain, it also delegate that details to another layer.
Any Domain Logic is handled by a Handler dedicated to each Resource action.
This allows me to handle the request for each Resource action in the same way, no matter is source.
So the Handler can receive requests from a Controller, Console or Socket and will always deal with them without knowing the the source of the request, neither the type of response it has to return, because the input and output will be always an Immutable Value Object or scalar values.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi James, thanks for this good article in explain why we should avoid the CRUD trap ;)
When coding I prefer to be explicit over implicit once I also prefer to use the domain level language to define each action for the resource being requested.
I split my folders structure as
resource/action, so for routeaccount/{id}/debitI would end up with a controller insrc/Resources/Accounts/Debit/AccountsDebitController.extension...This is what I call the Resource Design Pattern, that allows us to achieve more easily SOLID and Clean Code and at same time acts as documentation for the project.
Once the folder structure reflects all actions available for each resource this will be the type of documentation that never goes out of sync with the project, therefore never lies ;).
Cool. That's a nice structure. I'm generally using JAX-RS so I create a controller for the overall entity type, then have a method for each action. This works ok because my domain logic is delegated to a separate layer so the REST controller is generally just translating between the REST protocol and the domain logic's interfaces. However if I did one controller per action, your directory structure would work well.
My Controller don't have any logic related with the Domain, it also delegate that details to another layer.
Any Domain Logic is handled by a Handler dedicated to each Resource action.
This allows me to handle the request for each Resource action in the same way, no matter is source.
So the Handler can receive requests from a Controller, Console or Socket and will always deal with them without knowing the the source of the request, neither the type of response it has to return, because the input and output will be always an Immutable Value Object or scalar values.