DEV Community

Discussion on: There is No U in CRUD

Collapse
jlhcoder profile image
James Hood Author

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.

Collapse
exadra37 profile image
Paulo Renato

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.