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

Christopher H. Laco claco at chrislaco.com
Thu Aug 11 16:17:39 CEST 2005


David Storrs wrote:
> 
> On Aug 11, 2005, at 9:43 AM, John Siracusa wrote:
> 
>> On 8/11/05 9:15 AM, David Storrs wrote:
>>
>>>
>>> A very good case can be made for the idea
>>> that the Model should be just a thin wrapper over the DB and that the
>>> Controller (notice the name) should be the 'smart' thing in the
>>> system.  Not everyone will agree with this view and it isn't the
>>> classical MVC view but neither of those things makes it wrong.
>>
>>
>> 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.
>>
>> 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.
> 
> 
> 
> All true, but orthogonal to what I'm talking about.  Let's say you  
> define your generic ShoppingCart.pm module. Some part of your MVC app  
> needs to know which functions to call in ShoppingCart.pm--what I've  
> been talking about is what part that should be, the M or the C.
> 
> --Dks

IMHO, Model. Maybe today it's ShoppingCart.pm...maybe next month it's 
NewImprovedShoppingCart.pm. Assuming the APIs have changed, you wouldn't 
want to have to go around changing controllers; you would just change or 
rewrap the method name in the Model.

That does bring up the question of preparedness vs. to much work. Should 
the ShoppingCartModel in this case have it's own methods wrapping the 
ShoppingCart.pm methods...a duplication of code, but a true seperation 
in case of change. Or is ShoppingCartModel use-basing ShoppingCart.pm 
enough for now?

-=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/7a4e3fcf/smime-0001.bin


More information about the Catalyst mailing list