Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: ValueObject with an update() method  (Read 9602 times)
Joel Hooks
Courseware Beta
Sr. Member
***
Posts: 146


baby steps

 - 46288188  - passport@provinsal.com  - joeltuff
View Profile WWW Email
« 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 ;)
Logged

http://joelhooks.com - my ramblings about developing with actionscript and python using pureMVC and django respectively.
Tekool
Sr. Member
****
Posts: 192


View Profile WWW Email
« Reply #1 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.
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #2 on: October 02, 2008, 05:10:22 »

Nothing wrong with such a utility method existing on a VO.

-=Cliff>
Logged
Tekool
Sr. Member
****
Posts: 192


View Profile WWW Email
« Reply #3 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).
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #4 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> 
Logged
Joel Hooks
Courseware Beta
Sr. Member
***
Posts: 146


baby steps

 - 46288188  - passport@provinsal.com  - joeltuff
View Profile WWW Email
« Reply #5 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.
Logged

http://joelhooks.com - my ramblings about developing with actionscript and python using pureMVC and django respectively.
Pages: [1]
Print