[Newbies] Proxy objects

Michael van der Gulik mikevdg at gmail.com
Thu Jan 10 23:49:29 UTC 2008


On Jan 11, 2008 12:19 PM, cnantais <cnantais at gmail.com> wrote:

>
> Can someone recommend a good read on how to use proxy objects in
> Smalltalk?
>
> I'm trying to verify expectations about the messages that classes are
> receiving (as is done in rSpec, the Ruby BDD framework) and I think proxy
> objects may be the right pattern.
>


Typically you'd make a subclass of ProtoObject and write a
doesNotUnderstand: method that does what you want. However, this is fraught
with many dangers and crashed images. Another way is to modify the virtual
machine, which is the approach taken by Craig Latta's Spoon project.

Try my MessageCapture package, from http://www.squeaksource.com/DPON. It
contains a MessageCapture class. I can't remember exactly how it's used, but
it's something like:

m := MessageCapture captureFrom: anObject forwardTo: aReceiver.

And then you implement a reciever object which implements some method like
"handleMessage: m". You'll have to read the source; it's been hours since
I've touched this stuff so I can't remember what the actual methods were.

This package contains a bunch of things which make it much easier to manage
these message capturing objects, such as (mostly) being able to use the
debugger and inspector on them.

A message capture can't easily be stored in a dictionary, because the
dictionary calls "hash" on it. As an effect of this, you can't use them in a
workspace. Also, don't try using an Object Explorer on them. Sometimes alt-.
may help, sometimes it won't.

Also, save your code often and keep backups.

Gulik.

-- 
http://people.squeakfoundation.org/person/mikevdg
http://gulik.pbwiki.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/beginners/attachments/20080111/08132477/attachment.htm


More information about the Beginners mailing list