MVCR pattern (was Re: [Catalyst] Bing!)

Christopher H. Laco claco at chrislaco.com
Thu Aug 11 15:55:24 CEST 2005


John Siracusa wrote:
> IME, tying any "base functionality" to your webapp is a mistake.  Take an
> online store, for example.  Consider these functions: logging in, adding an
> item to the cart, deleting an item form the card, updating quantities in the
> cart, adding a credit card, making a purchase, charging the credit card,
> producing a receipt, logging out.  All of these functions should be in
> modules that have no ties whatsoever to the web or a webapp.

I agree 100%. That's the stance I took with Handel. It's easy to think 
of a shopping cart as an online thing living on the web, but that's not 
really the case. Why shouldn't I be able to add/edit/update/complete the 
cart/order from the command line, or from a Tk GUI app, or SOAP, or even 
email? I think the same applies to any good web app. The core should be 
reuable anywhere and not make assumptions about where it's being run.

> 
> What the webapp should do is provide a UI for these functions, and add any
> business rules that may vary.  For example, while the underlying module may
> allow any receipt to be viewed, the webapp would enforce a constraint that
> only allows users to view their own receipts.
> 
> This separation of the base functionality into generic modules is important
> because there are almost always multiple interfaces to the same
> functionality.  For example, the store administration and customer support
> tools want to look at everyone's transactions, account info, and receipts.
> Another example: batch jobs running via cron might want to empty or delete
> carts that haven't been used in a while.
> 
> All of these "applications" should use the same set of base modules to do
> their actual work, while providing their own additional constraints as
> appropriate.  If you tie any of this functionality to a webapp (i.e., by
> putting it in a "controller"), you will regret it as you are forced to
> duplicate the functionality elsewhere.
> 
> -John

So where does that leave us then...that those rules or additional 
contraints go into the modules used by the Model wrapper, or the Model 
rwapper itself? I think the former, not the latter. I tend to think of 
the Model as nothing more than a wrapper that in a worst case scenerio 
has to shuffle data formats to make the stash, possible the view happy.

I'm my case, Model really is just a wrapper around the core libraries 
and the controller deals with server/browser specific issues.

-=Chris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3178 bytes
Desc: S/MIME Cryptographic Signature
Url : http://lists.rawmode.org/pipermail/catalyst/attachments/20050811/b142f0a0/smime.bin


More information about the Catalyst mailing list