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

Steve Alexander steve@cat-box.net
Fri, 15 Dec 2000 11:51:07 +0000


Itai Tavor wrote:

> 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?

Sounds to me like you have a new type of Product.

You have your basic products (of which there are many kinds), and you 
have ProductWithGraphic products. A ProductWithGraphic is a "calculated 
product": it is composed of a basic product and a graphic. Its cost, 
delivery time, packing charge, and so forth, are calculated based on the 
combination of the basic product and the graphic.

To the rest of the application, a ProductWithGraphic is just another 
kind of product.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net