[Arp] The right way to use VO/TO's

Zoltan Csibi zoltan at thesilentgroup.com
Tue Mar 21 08:01:52 PST 2006


I will describe below a worst case scenario (which is also due how the flash
player deserializes amf data, of course this can be implemented in a better
way, here just for demonstration!!!):

Class TimeSheetEntry
{

Var starttime;
Var endtime;
Var timeworked;

Set Start(value)
{
   starttime = value
   ComputeTimeWorked()
}

Set End(value)
{
   endtime = value
   ComputeTimeWorked()
}

ComputeTimeWorked()
{
   timeworked = endtime - starttime;
}

}

Now you send to the server a TimeSheetEntry instance...if you are not
storing the "timeworked" too in the database (or computing it on the server
side upon retrieval)...on the next access your "timeworked" will not be
valid.

Matt's question I guess is especially important when:
- your class has constructor with arguments
- your class needs some explicit initialization (calling some method)

In these cases it makes sense to send just "plain" TOs and not the actual
objects.

....from patterns point of view Transfer Objects should only encapsulate and
transport business data.

Zoli


-----Original Message-----
From: Arp-bounces at ariaware.com [mailto:Arp-bounces at ariaware.com] On Behalf
Of Chris Velevitch
Sent: Tuesday, March 21, 2006 4:07 PM
To: General List for Ariaware RIA Platform users and developers
Subject: Re: [Arp] The right way to use VO/TO's

On 3/22/06, Matt Brailsford <mpb at logicalminds.co.uk> wrote:
> I agree with your view on validation, it is technically deciding 
> whether to accept the data or not, but I guess this is the necessary 
> evil that is validation.

I think one tends to forget that business requirements/logic consists of a
number of parts: what type of data the system needs to handle, how do
display that data, how to send that data, where to send that data, how to
store it, etc.

> What I meant with my other question was, do you send the object that 
> contains methods back to the server, or do you copy the data to an 
> object that purely contains data? ie a transfer object.

I'm still not understanding. You seem to be saying that there is a feature
or mechanism that allows you send the AS2 class definition of the instance
with all the method code as well as the data across the wire to the server,
even though the server maybe Coldfusion or Java or PHP, when that object
arrives on the server, the server can then call any of the methods of the
AS2 class definition of the object instance that is now on the server. If
that's what you saying, I didn't know you could do that. I'm using Flash
Remoting calls to CFC methods passing that data as arguments that are either
simple types, or arrays of plain AS2 dynamic objects which are mapped into
the corresponding types on the server by the server component of Flash
Remoting or that's how I understand it to work.


Chris
--
Chris Velevitch
Manager - Sydney Flash Platform Developers Group www.flashdev.org.au

_______________________________________________
Arp mailing list
Arp at ariaware.com
http://ariaware.com/mailman/listinfo/arp_ariaware.com


--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.385 / Virus Database: 268.2.6/286 - Release Date: 3/20/2006




More information about the Arp mailing list