[Nitro] Concerns over Og mandating the form of initialize

James Britt james_b at neurogami.com
Wed Apr 13 09:35:00 EDT 2005

George Moschovitis wrote:
>>Perhaps this could be replaced with something that first tries to
>>populate the object by passing a block to klass.new.
> ok, but where does this block come from?

In the Og code, as part of the routing that creates an object.  The 
current code lops over a hash of properties/values and uses that to set 
object values.  That assignment can happen in a block.
> when reading (deserializing) an object from the store (rdbms) I dont want 
> to call the constructor at all. Perhaps there is a method to allocate the object
> without calling klass.new. I think this was added in 1.8.2

YAML and Marshal can deserialize without calling the constructor.  But 
there is the question of whether serialization is meant to preserve 
specific objects, or a set of values, and if deserialzation is meant to 
  recreate previous objects, or create new objects with pre-existing values.

If new objects are to be created, then calling initialize is perhaps the 
better path because it allows for the object to create any required 
internal state as well as do a sanity check on on the data used.

If pre-existing objects are to be used, then one has to guard against 
other processes altering the database.


More information about the Nitro-general mailing list