[Catalyst] Sending Email from Page?
John M. Dlugosz
wxju46gefd at snkmail.com
Mon Mar 28 12:22:30 GMT 2011
On 3/27/2011 12:22 PM, Tomas Doran bobtfish-at-bobtfish.net |Catalyst/Allow to home| wrote:
> And I would say that sending an email is a state change, and behavior of the application
> domain here.
That's a stretch, because you can argue that any side-effect is a change of state to the
universe at large and there happens to be no accessor to read the results of the change.
It clearly matches "side effect", not "state", unless you stretch the definition to make
all side effects into state and lose all distinction.
>> An arbitrary helper subroutine used by the Controller is not a Model. Since it is
>> side-effect only, it matches one of the links in the graph (Controller TO Model) so it
>> "fits" in the architecture provides the proper connectivity. But that is a kludge, not
>> its proper usage.
> Again, I think that the sending of email from the application is _very much_ behavior.
If "behavior" includes causing side effects, sure. That is certainly something the
Controller is allowed to do, and is the Controller's responsibility.
> In future you may want to replace the implementation of it, or wrap it with extra
> functionality (e.g. to count the number of emails sent), or reuse it in an application
> context beyond the web app (e.g. sending email from a batch script).
So? That is an argument for encapsulation and abstraction, not for making it a Model.
> With a model all of these things are not only possible, they're easy, and you've got a
> framework for the abstraction and use outside Catalyst already provided...
I think we are in agreement that using the auto-discovery/loading, and the dissemination
of settings, and whatever else a Catalyst component does for you, might be handy for
writing helper code, as opposed to making it a plain Perl module.
But that doesn't make it a "Model". Saying it is (to promote auto-discovery and loading)
is just a hack, done for that purpose only.
More information about the Catalyst