pmjones / adr

Action-Domain-Responder: a web-specific alternative to Model-View-Controller.
http://pmjones.io/adr
1.13k stars 64 forks source link

Is it the responsibility of the Action to call the responder? #38

Closed mnapoli closed 9 years ago

mnapoli commented 9 years ago

In your examples, the action calls the responder. Is there a reason for that? Shouldn't it be the routing system that does that (when using a router that can do that of course)?

pmjones commented 9 years ago

Is it the responsibility of the Action to call the responder?

Not necessarily. The primary point here is in how the concerns are separated. As long as the response-building work is separated from everything else, the "action" ends up being so trivial as to be (almost) nonexistent. Having said that, having the action call the responder seems to make the most sense. Cf. the Arbiter library, which is a uniform/universal action system capable of invoking any domain callable and any responder callable.

p.s.: It seems to me that "calling a responder" is out-of-scope for a router, in the same way that "calling the domain" would be out-of-scope. A router identify the route information, then hand that route off for dispatching. But maybe that's just me.

mnapoli commented 9 years ago

Thanks that answers my questions.

It seems to me that "calling a responder" is out-of-scope for a router, in the same way that "calling the domain" would be out-of-scope. A router identify the route information, then hand that route off for dispatching. But maybe that's just me.

No I agree with that too ;) I don't expect a router library to do this (e.g. Aura Router). But sometimes in a framework you can consider "the router part" (request-route matching, dispatching, …) as a whole and that's more what I had in mind (i.e. I wasn't using the best words ;) ).

pmjones commented 9 years ago

(/me nods)

Fair enough. Let me know if you have other questions/comments!