On Fri, 11 Apr 2003 22:56:53 +0900
Dave Thomas <dave / thomases.com> wrote:

> 
> Just wondering... why are the .allocate methods public? Using them, I 
> can bypass the initialization that the class designer intended for 
> objects, and so break class invariants.
> 

THIS IS GOOD.  (Actually.)  ;-)  It allows one to allocate an object,
do things to it, then call initialize manually.  This is _extremely_
useful.

For instance, in Mephle, I use this to initialize instance variables
@_oid, @_volume, @_owner, and (optionally) @_server.  Without these,
when initialize is called, there is no way to allocate other persistant
objects, since the object itself doesn't know where it exists!

(Passing these as parameters is unacceptable.  Not only is it extra
overhead for the coder, it prevents preexisting classes from fitting
into the scheme.  Currently I have @_oid et al. added to Object,
along with the proper Object#new_on(connection, volume, ...) for
allocation.  It works _very_ well.)

I had to move to ruby 1.8 because #allocate was necessary for this
system.  There really is no other good way.

-- 
Ryan Pavlik <rpav / users.sf.net>

"That's the first pratical line of thinking to
 come out of your word hole since we first met." - 8BT