A note on why to not use lazy initialization ...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

A note on why to not use lazy initialization ...

Dennis smith-4
We use lazy initialization alot -- for good reasons
    we use Gemstone and its more efficient to store "nil" than
    some intialized value.  We use read accessors which
    can initialize if required.

However, I just spent a few hours debugging a randomly occurring
problem.  We have quite a bit of thread-safe code (supposed to be).
Anyway, in another process a read accessor was referenced which
tried to initialize and kicked off a gemstone reference and a full
transaction and commit which in our transaction handling invoked
a "self error" because the transaction object (not thread safe)
was accessed.

Good reason to be very careful of lazy inits -- my fix in this case will be
to initialize the value.

--
Dennis Smith                         +1 416.798.7948
Cherniak Software Development Corporation   Fax: +1 416.798.0948
509-2001 Sheppard Avenue East        [hidden email]
Toronto, ON M2J 4Z8              sip:[hidden email]
Canada         http://www.CherniakSoftware.com
Entrance off Yorkland Blvd south of Sheppard Ave east of the DVP