PureMVC Architects Lounge

Announcements and General Discussion => Architecture => Topic started by: Joel Hooks on October 01, 2008, 06:54:57



Title: ValueObject with an update() method
Post by: Joel Hooks on October 01, 2008, 06:54:57
I've put an update method on my ValueObjects in my current project. It takes an object of the same type as an argument, checks against the UID, and replaces all of the other values if the UID is a match. It seems really handy when I am updating objects from forms and whatnot, but I wam wondering, is this just bad form? It makes me feel a little dirty ;)


Title: Re: ValueObject with an update() method
Post by: Tekool on October 01, 2008, 08:46:28
Is your project an Actionscript project ? Because what you've made is a sort of your own DataBinding implementation. If it is an Actionscript project (I suppose it is not) you would prefer to use databinding mechanisms.

If the update direction is from the form to the model I would have preferred to send a notification that a command will catch because sending a form is a typical controller role or at least just call a proxy from your form view mediator.

If the update direction is from the model to the form I would have preferred to send a notification that your form view mediator will catch to update the form.


Title: Re: ValueObject with an update() method
Post by: puremvc on October 02, 2008, 05:10:22
Nothing wrong with such a utility method existing on a VO.

-=Cliff>


Title: Re: ValueObject with an update() method
Post by: Tekool on October 02, 2008, 06:28:05
Cliff you do not think that this could be a bad practice to use this if multiple clients listen and receive update events from the same VO ? For my part, it seems to come as a clone   implementation of notification supports when a simple notification could do the job (in the goal to keep it simplest as possible).


Title: Re: ValueObject with an update() method
Post by: puremvc on October 02, 2008, 09:48:42
It all depends on what your desired result is. If you want to set a VO as a data provider in multiple places and manipulate it anywhere, without setting off a round of notifications, you can certainly do it and it is simple because the PureMVC aparatus isn't involved. Anything binding to those fields will be automatically updated.

This may not be what you want in every case, but an update method such as Joel describes is basically just a multi-field setter.

-=Cliff> 


Title: Re: ValueObject with an update() method
Post by: Joel Hooks on October 03, 2008, 10:23:36
I couldn't stand the smell, so I put my update apparatus in individual proxies for the VOs. I decided that I didn't want the view updating my model at all, and figured that it would create dirty objects. So now, to update an object it has to be saved to the database, which triggers the round of notifications that the object has been updated. Obviously you could still update the properties from anywhere (I really need to get/setterize them all), but I think I can take that out too and have my proxies fully marshaling the ValueObjects.

Smells like peaches instead of poo.