Well, then my take would be this: since you are sending them from CF, you
are probably using AMF, and since you do so, you can use strongly typed
objects, and (again, I'm not sure but...) I think that strongly typed
objects are written accordingly to their describeType - this means objects
are going to be consistent when serialized. But, the thing with comparing
serialized objects is more of a trick, then a really good design. I would go
for some kind of equals():Boolean method for those objects and implement it
in a way it would only compare the relevant data.
Something more like this:

class BusinessObject {

public function equals(object:BusinessObject):Boolean {
    if (this.foo != object.foo) return false;
    if (this.bar != object.bar) return false;
    return true;
}
}
This would cover all the cases, like when you want the objects to have only
some unique properties, but other you don't mind. It will be also easier
to maintain in the long run. This is an inherent problem of OO languages vs
rrelational database languages, where the first implies that objects must
have unique identity and the second believes that the objects that have all
the same traits are the same. Of course this is not black and white, but
it's a known problem. The equals-like method is probably the standard kind
of solution to this problem, unless you can find some more optimized way to
do it.
There are more interesting things, for example, if you implement valueOf()
method of an object in a way that it returns number or string, the
implementors may be treated under certain circumstances as being of simple
type, so, say and you have something like this:

class BusinessObject {

public function valueOf():Object {
    return int(this.foo + this.bar);
}
}
Then you can cast BusinessObject to int and compare ints :)

var bo0:BusinessObject = new BusinessObject(100, 200);
var bo1:BusinessObject = new BusinessObject(100, 300);

if (int(bo0) === int(bo1)) // objects are assumed equal.

This approach may be more efficient if you cache the valueOf value in
the BusinessObject so that when called it only returns the value.

Reply via email to