Hi Bill --

> I, like many, find these discussion really interesting.  I always wish
> there was some write up for the mod_perl site when all was 
> said and done.
> But I guess one of the reasons it's so interesting is that 
> there's more
> than one correct point of view.

I expect to complete an article on this exact topic in the next month which
is scheduled to appear in one of the major Perl-related publications.  I'll
try to keep my typically unyielding and vitriolic opinions in check.  :-)


> My MVC efforts often fall apart in the C an M separation.  My 
> M parts end
> up knowing too much about each other -- typically because of error
> conditions e.g. data that's passed to an M that does not 
> validate.  And I
> don't want to validate too much data in the C as the C ends 
> up doing M's work.

First off, it is less of an "MVC crime" to combine your Model and Controller
than it is to combine your Controller and View.  In fact, on a small
application which is not going to be used in a radically different way
anytime soon it makes very good sense to do so!  Investing in writing
reusable code without a (re)use-case in mind is a waste of time and money.
Don't build it -- you won't need it!

Assuming you have a (re)use-case in mind for your Model, handling errors is
pretty easy.  If some code calls a method in your model with invalid
arguments just throw an exception!  Handle errors just like you would in any
method!  Don't get hung up on the fact that this is the "Holy Model".  It's
just a method.  Don't be afraid to croak() if the situation deserves it.
This is basic exception handling, and all the usual techniques (or, in Perl,
the lack thereof) apply.


TTYL,

-Jesse-

Reply via email to