Simple extensions to Progress.Lang.Object

Posted by Thomas Mercer-Hursh on 12-May-2010 14:13

Following the discussion here http://communities.progress.com/pcom/thread/27093 and other off list exchanges, I have add four new requests to the ERS as follows:

0000004045 – Add ID or Handle attribute to Progress.Lang.Object.
It is necessary at times in OO programming to determine where two different object references point to the same object.  I propose adding an ID or Handle attribute to Progress.Lang.Object such that one can make tests of the form “IF ObjRef1.ID = ObjRef2.ID THEN”.
Currently, one can use “int(ObjRef1) = int(ObjRef2)” for this test, but this is more obscure than a simple attribute.
0000004046 – Add WRITE-XML and READ-XML to Progress.Lang.Object
There are many cases in which one wants to serialize an object, e.g. to transmit it over the wire, to store it, or to capture its state following the Memento pattern.  We have an excellent serialization mechanism for Temp-Tables, ProDataSets, and buffers in the WRITE-XML and READ-XML methods.  These should be added to Progress.Lang.Object to write out the current value of all data members in the object.  Included in this proposal would be to support XML-NODE-TYPE on properties and variables in objects in order to specify that a data member be excluded from the XML.  The default value of ID in request 4045 should be HIDDEN since that should be a non-settable attribute.  If an objects state has been saved and then restored via READ-XML, it is still the same object and should have the same ID, but if a new object is created from saved or transmitted state, then it would have a new ID.
This feature would provide rapid and universal serialization and deserialization functionality for all ABL objects.
The only workaround is to manually code the serialization in every class, which is not only labor intensive, but would provide poor performance compared to the proposed feature.  Putting all data members in a temp-table is not practical because of the overhead of using temp-tables.
0000004047 – Add GUID to Progress.Lang.Object
With reference to Enhancement Requests 4045 and 4046, if an object has been serialized and then reconstituted as a new object, either after transmission or being stored, it will have a new object ID.  It is desirable to have a mechanism which would allow one to tell whether such a new object was the same as another object.  E.g., if an object is serialized and sent to a client where it is de-serialized, processed, re-serialized and returned to the original session where it is deserialized into a new object, one would like to be able to tell which existing object this new object was derived from.  The ObjRef.ID proposed in 4045 will not do this since it will be a new object.  Therefore, one should add a GUID attribute to Progress.Lang.Object which will be serialized with the rest of the object’s data members in order to identify which original object this object was derived from.
This feature provides object identity across serialization-deserialization boundaries.
There is no workaround other than adding the GUID property separately to every class.
0000004048 – Add Hashcode attribute to Progress.Lang.Object
It is desirable in OO programming to be able to determine when two objects are effectively clones of one another, i.e., they are the same type and have the same state.  The ID proposed in 4045 provides an easy way to identify whether they are actually the same object and we already have the ability to tell if they are the same type, but there is no quick way to tell if they have the same state other than attribute by attribute comparisons and, even there, any private state can not be compared.  Therefore, it is proposed to add a Hashcode property to Progress.Lang.Object which would serialize the data members of the object into XML (see 4046), excluding the ID from 4045 and the GUID proposed in 4047 as well as any properties or variables with XML-NODE-TYPE marked as HIDDEN as per 4046 and then compute a SHA1-DIGEST of this XML and present this as an attribute of Progresss.Lang.Object
This attribute would provide extremely rapid comparison of object state equality.
There is no workaround other than to manually implement this functionality in every class.

All Replies

Posted by Tim Kuehn on 23-May-2010 07:59

tamhas wrote:

Following the discussion here http://communities.progress.com/pcom/thread/27093 and other off list exchanges, I have add four new requests to the ERS as follows:

0000004045 – Add ID or Handle attribute to Progress.Lang.Object.
It is necessary at times in OO programming to determine where two different object references point to the same object.  I propose adding an ID or Handle attribute to Progress.Lang.Object such that one can make tests of the form “IF ObjRef1.ID = ObjRef2.ID THEN”.
Currently, one can use “int(ObjRef1) = int(ObjRef2)” for this test, but this is more obscure than a simple attribute.
...
0000004047 – Add GUID to Progress.Lang.Object
With reference to Enhancement Requests 4045 and 4046, if an object has been serialized and then reconstituted as a new object, either after transmission or being stored, it will have a new object ID.  It is desirable to have a mechanism which would allow one to tell whether such a new object was the same as another object.  E.g., if an object is serialized and sent to a client where it is de-serialized, processed, re-serialized and returned to the original session where it is deserialized into a new object, one would like to be able to tell which existing object this new object was derived from.  The ObjRef.ID proposed in 4045 will not do this since it will be a new object.  Therefore, one should add a GUID attribute to Progress.Lang.Object which will be serialized with the rest of the object’s data members in order to identify which original object this object was derived from.
This feature provides object identity across serialization-deserialization boundaries.
There is no workaround other than adding the GUID property separately to every class.
0000004048 – Add Hashcode attribute to Progress.Lang.Object
It is desirable in OO programming to be able to determine when two objects are effectively clones of one another, i.e., they are the same type and have the same state.  The ID proposed in 4045 provides an easy way to identify whether they are actually the same object and we already have the ability to tell if they are the same type, but there is no quick way to tell if they have the same state other than attribute by attribute comparisons and, even there, any private state can not be compared.  Therefore, it is proposed to add a Hashcode property to Progress.Lang.Object which would serialize the data members of the object into XML (see 4046), excluding the ID from 4045 and the GUID proposed in 4047 as well as any properties or variables with XML-NODE-TYPE marked as HIDDEN as per 4046 and then compute a SHA1-DIGEST of this XML and present this as an attribute of Progresss.Lang.Object
This attribute would provide extremely rapid comparison of object state equality.
There is no workaround other than to manually implement this functionality in every class.

Handles currently use "unique-id" to fulfill the latter requirement, and I'm thinking could fulfill the former requirement.

Posted by Thomas Mercer-Hursh on 23-May-2010 12:03

A unique-id is somewhat parallel to the proposed GUID, but somewhat different in purpose.  The GUID is intended to identify "same as" when an object has been serialized and deserialized and thus has a different "handle". Unique-id is the flip of this, i.e., identifying that the query currently occupying a handle is not the same query as previously occupied the handle.  But, close enough in meaning that I wouldn't object to them calling the property unique-id instead.

This is quite different than hashcode, however, which is used to identify that two objects have the same state even though they are not the same instance.  This concept doesn't really apply to something like a query unless you considered things like the current cursor position and any other state aspects of the query in the comparison.  Moreover, the whole point of hashcode is to compare objects which are not the same instance.  That would be like having two queries with different handles but the same where clause, lock state, cursor position, etc.

Posted by bsgruenba on 25-May-2010 14:58

"0000004046 – Add WRITE-XML and READ-XML to Progress.Lang.Object"

This should closely follow the JAXB 2.2 model where serialization is done means of annotations. One should be able to mark what is added as an element and what is added as an attribute. It should also be possible to specify a root element for the class as a whole.

Posted by Thomas Mercer-Hursh on 25-May-2010 15:12

Rather than annotations per se, my inclination is to go along with the mechanisms that we have elsewhere for WRITE-XML like XML-NODE-TYPE.

What else do you want?

How is the root something other than the class itself?

This thread is closed