[Nitro] Concerns over Og mandating the form of initialize

George Moschovitis george.moschovitis at gmail.com
Wed Apr 13 15:16:48 EDT 2005

> applications to be able to create or alter data. I see this as a feature.


> When my Nitro app reads data and creates objects, I want to be sure the
> created objects are well-constructed.

you can add a og post-read callback to validate the object. (In the
next version this will be much easier and powerful, thanks to the
> What would be the overhead of saving an object's properties as simple
> data, but also using an extra field to store a YAML serialization, and
> ...
> values in the database, or revive existing objects from the saved
> serialization?

this feels wrong. You are duplicating the data. Plus there is another
problem. If you attach a yaml representation to every DBMS row, you
cant have constant length records (which are much faster to traverse
by the DBMS system).

BTW, I think it is wrong to call the initialize method when an object
is deserialized. In the initialize method I may put code that should
be called when the object is initialized, ie created for the first
time. For example I could have code for reference counting in the

def initialize 
  Statistics.num_of_blogs += 1

It would be bad to force this code executed every time the object was

If you want to ensure a valid state for your object you could do the
following (some 0.16.0 concepts here):

class MyObject

  # 0.16.0 aspect to intercept lifecycle callback
  post :make_valid, :on => og_read

  def initialize(...)

  def make_valid
    # ensure a valid state for the object


then make_valid is called after (post) each object is deserialized (read) from
the DBMS.

does this make sense to you?



More information about the Nitro-general mailing list