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

2000-12-21 Thread Phillip J. Eby

At 05:13 PM 12/21/00 +1100, Itai Tavor wrote:

I think you're right about this being an OrderLineItem.  A couple of fine
points, however...  First, I don't think there needs to be an
"OrderLineItemsWithGraphic" specialist, since there is nothing else that
would talk to it.  It's fine in this case to have the line item classes
(either with graphic or without) handle their own UI snippets.  UI
delegation is for when an object needs to display UI for some *other*
object than itself, since you can always use class extenders and other
techniques to reshape the apparent class of an object retrieved from a
specialist.  The interface which other objects deal with is
"OrderLineItem", and they simply expect a portion of the form to be
rendered, and it's okay for the class to handle that.

I got a bit confused here... the UI snippet for uploading a graphic 
actually comes from the Graphics Specialist.

That's fine, but it should be by way of an object that's filling the
OrderLineItem role, yes?

Or I could 
eliminate the problem by uploading the graphic from a form displayed 
by the order line item after it has been added.

That's actually what I thought you were doing/intending.


Here's the question...  how many behaviors are different in the order line
item itself?  Are you also using fulfillment line items?  If the only
difference to the order line item is that it references some additional
data, then I'd say a single class would be fine.  Most of the behavior
probably comes in on the fulfillment line item, yes?  Again, you can ask
your FulfillmentLineItems specialist to create
"newLineItemFor(orderLineItem)" and let it decide what kind of
implementation to hand back.  In this case, it probably will be a different
class, while for the order line items, it may or may not buy you anything.

I haven't thought of using fulfillment line items... not sure what 
they are for? An order is considered fulfilled once all items have 
been shipped, so order line items are responsible for tracking 
everything that happens until a ShipmentLineItem is created. The 
order line item for a customizable product tracks the product using 
state values like 'sent to factory', 'received from factory', etc. So 
it needs a new set of state values, as well as methods like 
'sendManufacturingOrderToFactory'.

What exactly does the fulfillment role you're referring to do? Does 
it do more than a shipment role?

Fulfillment would be between ordering and shipping, covering such things as
pulling items from the warehouse to customizing them with the graphic.  I
assumed that an order line item was only meaningful until you have a
completed order.  You may not need the complexity, but to me it seems like
a seperate phase with a very different set of behaviors than what I would
think of as an order line item.  If I were doing an app like this, I'd at
least have some sort of state/status objects to delegate these different
behaviors to.  But I'd say this could be left to the taste of the chef.  :)

P.S.  By the way, I'm off on vacation later today, and won't be active on
the list again for a little over a week.


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




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

2000-12-20 Thread Itai Tavor

Phillip J. Eby wrote:

This should probably be more like:

product.addMeToOrder():
   item = OrderLineItems.newLineItemFor(self)
   item.setQuantity(...)
   etc.
   order.addLineItem(item)

customizable_product.addMeToOrder():
   item = OrderLineItems.newLineItemFor(self)
   item.setGraphic(...)
   item.setQuantity(...)
   etc.
   order.addLineItem(item)

This approach makes things more declarative.  The product classes can have
properties or interfaces that the OrderLineItems specialist can use to
decide what kind of line item would serve them best.  You can then change
your line item assignment rules without necessarily requiring changes to
the product classes.

Yeah, it does work much better your way. And, getting OrderLineItems 
to decide on its own which type of object to add - haven't thought 
about doing it this way before. Thanks - something new to meditate on.


  I imagine, then, that the UI for uploading the graphic would be
included in product.addMeToOrderForm, using a UI snippet from the
OrderLineItemsWithGraphic Specialist. Then I could pass REQUEST on to
order.addLineItem and to OrderLineItemsWithGraphic.add, which would
then upload the file?

I think you're right about this being an OrderLineItem.  A couple of fine
points, however...  First, I don't think there needs to be an
"OrderLineItemsWithGraphic" specialist, since there is nothing else that
would talk to it.  It's fine in this case to have the line item classes
(either with graphic or without) handle their own UI snippets.  UI
delegation is for when an object needs to display UI for some *other*
object than itself, since you can always use class extenders and other
techniques to reshape the apparent class of an object retrieved from a
specialist.  The interface which other objects deal with is
"OrderLineItem", and they simply expect a portion of the form to be
rendered, and it's okay for the class to handle that.

I got a bit confused here... the UI snippet for uploading a graphic 
actually comes from the Graphics Specialist. If I want to let the 
user upload the graphic as part of the product's addToOrderForm, 
Product needs to get this snippet - but Products and Graphics don't 
know about each other in the object model, so Product would have to 
ask OrderLineItems (not OrderLineItemsWithGraphic  - I clearly don't 
need that) to get the snippet from Graphics for it, because it would 
violate Demeter if it talked directly to Graphics... Or I could 
eliminate the problem by uploading the graphic from a form displayed 
by the order line item after it has been added.


Second, you need to define that interface so that the Order can give the
line item constraints on how it does that UI, so it can share the screen
and REQUEST with other objects/data that the Order needs.  One easy way to
do this is to use a namespace parameter, that simply gives the line item a
name prefix to use on its fields.  Alternatively, you can use the "record"
approach, like this:

INPUT TYPE="TEXT" NAME="lineitem1.desiredSize:record:int" VALUE="4"
INPUT TYPE="FILE" NAME="lineitem1.imageFile:record:file"
...

The resulting REQUEST object from submitting the form will contain a single
object, "lineitem1", with "desiredSize" and "imageFile" attributes, so
you'll only have to pass a single parameter back to the line item.  I've
never tried doing a record with a file in it before, so I don't really know
how well that works.

I've been solving the REQUEST sharing problem using a prefix on form 
fields... but I like the "record" idea - it makes it much easier to 
pass the form data around... I'll try it with a file soon. I imagine 
it would work fine.


  Woof... so long. I'd appreciate any comments on this - especially on
the question on whether it's better to have a specialized type of
OrderLineItem, or to link the standard OrderLineItem to a Product
object in case of a standard product, or, in the case of a
  customizable product, to a new object which stores the graphic and
tracks the fabrication of the customized item.

Here's the question...  how many behaviors are different in the order line
item itself?  Are you also using fulfillment line items?  If the only
difference to the order line item is that it references some additional
data, then I'd say a single class would be fine.  Most of the behavior
probably comes in on the fulfillment line item, yes?  Again, you can ask
your FulfillmentLineItems specialist to create
"newLineItemFor(orderLineItem)" and let it decide what kind of
implementation to hand back.  In this case, it probably will be a different
class, while for the order line items, it may or may not buy you anything.

I haven't thought of using fulfillment line items... not sure what 
they are for? An order is considered fulfilled once all items have 
been shipped, so order line items are responsible for tracking 
everything that happens until a ShipmentLineItem is created. The 
order line item for a 

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

2000-12-18 Thread Phillip J. Eby

At 04:21 PM 12/18/00 +1100, Itai Tavor wrote:

This is how I see it:

- Products Specialist
 productRack
 customizableProductRack

- OrderLineItem Specialist
 lineItemRack
 lineItemWithGraphicRack

- product.addMeToOrder():
 order.addLineItem(product_id=id, add='lineItem')

- custimazable_product.addMeToOrder():
 order.addLineItem(product_id=id, add='lineItemWithGraphic')

This should probably be more like:

product.addMeToOrder():
  item = OrderLineItems.newLineItemFor(self)
item.setQuantity(...)
  etc.
  order.addLineItem(item)

customizable_product.addMeToOrder():
  item = OrderLineItems.newLineItemFor(self)
  item.setGraphic(...)
item.setQuantity(...)
  etc.
  order.addLineItem(item)

This approach makes things more declarative.  The product classes can have
properties or interfaces that the OrderLineItems specialist can use to
decide what kind of line item would serve them best.  You can then change
your line item assignment rules without necessarily requiring changes to
the product classes.



I imagine, then, that the UI for uploading the graphic would be 
included in product.addMeToOrderForm, using a UI snippet from the 
OrderLineItemsWithGraphic Specialist. Then I could pass REQUEST on to 
order.addLineItem and to OrderLineItemsWithGraphic.add, which would 
then upload the file?

I think you're right about this being an OrderLineItem.  A couple of fine
points, however...  First, I don't think there needs to be an
"OrderLineItemsWithGraphic" specialist, since there is nothing else that
would talk to it.  It's fine in this case to have the line item classes
(either with graphic or without) handle their own UI snippets.  UI
delegation is for when an object needs to display UI for some *other*
object than itself, since you can always use class extenders and other
techniques to reshape the apparent class of an object retrieved from a
specialist.  The interface which other objects deal with is
"OrderLineItem", and they simply expect a portion of the form to be
rendered, and it's okay for the class to handle that.

Second, you need to define that interface so that the Order can give the
line item constraints on how it does that UI, so it can share the screen
and REQUEST with other objects/data that the Order needs.  One easy way to
do this is to use a namespace parameter, that simply gives the line item a
name prefix to use on its fields.  Alternatively, you can use the "record"
approach, like this:

INPUT TYPE="TEXT" NAME="lineitem1.desiredSize:record:int" VALUE="4"
INPUT TYPE="FILE" NAME="lineitem1.imageFile:record:file"
...

The resulting REQUEST object from submitting the form will contain a single
object, "lineitem1", with "desiredSize" and "imageFile" attributes, so
you'll only have to pass a single parameter back to the line item.  I've
never tried doing a record with a file in it before, so I don't really know
how well that works.


Woof... so long. I'd appreciate any comments on this - especially on 
the question on whether it's better to have a specialized type of 
OrderLineItem, or to link the standard OrderLineItem to a Product 
object in case of a standard product, or, in the case of a 
customizable product, to a new object which stores the graphic and 
tracks the fabrication of the customized item.

Here's the question...  how many behaviors are different in the order line
item itself?  Are you also using fulfillment line items?  If the only
difference to the order line item is that it references some additional
data, then I'd say a single class would be fine.  Most of the behavior
probably comes in on the fulfillment line item, yes?  Again, you can ask
your FulfillmentLineItems specialist to create
"newLineItemFor(orderLineItem)" and let it decide what kind of
implementation to hand back.  In this case, it probably will be a different
class, while for the order line items, it may or may not buy you anything.

Anyway...  remember that Specialists are there to hide implementation
decisions like what classes are being used.  If you look at the ZPatterns
Wiki you'll see references to some of the design patterns which Specialists
are an instance of, which will give you some hints as to the many kinds of
things they can "hide" for you (and which therefore you should avoid
revealing in other code).  One of those patterns is that as an object
"trader" or "broker", Specialists can be used to create new instances of
objects that meet a certain interface, but whose implementation has been
selected on the basis of declarative criteria by the requesters.


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




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

2000-12-15 Thread Steve Alexander

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


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )