On Jun 5, 2007, at 5:24 PM, Ariel Jakobovits wrote:

> I am learning about Cairgorm, and about the usage of Value Objects.  
> This makes sense. However, I am curious about how to handle basic  
> operations on these value objects.

I just went through the exact same learning curve.

I'm not an authority by any means, but what I did was:

1. Create a new command called "UpdateAssetCommand", or in your case  
"UpdateItemCommand"
2. Pass in through the cairngorm event the updated properties on your  
item.
3. Your UpdateItemCommand will then execute the appropriate update by  
grabbing the item from the Model, iterating over the properties and  
changing them. In my case, I have an ArrayCollection of VOs and just  
iterated over that collection until I got the asset in question and  
then updated its properties.

> When I pass an item to a form component, I am inclined to permit  
> the form component to perform update operations on the item like  
> item.assignToCategory(category); I think this is intuitive for the  
> design of the form component.

Just a side note : are you passing this item to the form component  
explicitly, or is it bound to the model – ie, data ==  
{model.selectedItem}. Binding to the model is much preferred.

Additionally, it shouldn't be against the grain to extend your item  
VO with a method to update it's properties based on a passed in  
Object, Array(Collection) or XMLList if you don't want to deal with  
assigning a bunch of properties by name in the Command. But you'd  
still do the actual updating in the command itself. I wouldn't do it  
in the form.

> But this means that the item value object is not just a model, but  
> also a controller in some aspect. The alternative as I understand  
> it is to say something like Controller.addCategoryToItem 
> (item,category) which is OK but I think it is sort of clunky.
>
> Direction? Advice? Am I missing something? Please.

I don't think you need to get that explicit with your commands.  
Commands should be generic enough (ie, updateItem) to reuse in  
different cases.

good luck with that,

jon

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/flexcoders/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to