[Zope-dev] ZPatterns, ZClasses, Specialists: Assigning responsibilities

Itai Tavor itai@optusnet.com.au
Fri, 15 Dec 2000 12:48:35 +1100


I'm having problems deciding where certain methods should be 
implemented. In some cases it's easy - for example, objects manage 
themselves, Specialists manage collections, so editInstanceForm 
belongs in the ZClass, while listOpenOrders belongs in the 
Specialist. But here are some cases where it's not as clear:

1. I want to edit an object from the editing form of another object. 
So I give my object an editInstanceSnippet method. It's very similar 
to editInstanceForm, except that it's not a full html document. 
Should it go in the ZClass? But it's a method used for application 
integration - so maybe it belongs in the Specialist?

2. In a typical shopping cart application, a Product object will be 
responsible for adding itself to an order, right? So the Product will 
have an addMeToOrderForm, which will call addMeToOrder, which in turn 
will call order.addOrderLineItem method. I think. But here's a 
complication: I have the following ZClasses, with matching 
Specialists: Product, Graphic, Order, OrderLineItem. When a customer 
adds a product to their order, they have to provide a graphic file 
which will be printed on the product (imagine buying a lunch box with 
your cat's photo on it). The Graphics Specialist can provide a 
addGraphicSnippet form. But who's responsible for asking for this 
graphic when adding the product to the order? Is it still the Product 
object? But a Product turns into a Product-with-Graphic only when 
it's a part of an order, so is it correct for the Product to even 
know about Graphics? the alternative is to move the addToOrder 
methods to either Order or OrderLineItems, but this doesn't make any 
more sense because these would then have to know a lot more about a 
Product than is good for them. Any ideas?

TIA

Itai
-- 
Itai Tavor                    "Je sautille, donc je suis."
C3Works    itai@c3works.com              - Kermit the Frog

"If you haven't got your health, you haven't got anything"