<br><br><div class="gmail_quote">On Jan 11, 2008 12:19 PM, cnantais &lt;<a href="mailto:cnantais@gmail.com">cnantais@gmail.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>Can someone recommend a good read on how to use proxy objects in Smalltalk?<br><br>I&#39;m trying to verify expectations about the messages that classes are<br>receiving (as is done in rSpec, the Ruby BDD framework) and I think proxy
<br>objects may be the right pattern.<br></blockquote></div><br><br>Typically you&#39;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&#39;s Spoon project.
<br><br>Try my MessageCapture package, from <a href="http://www.squeaksource.com/DPON">http://www.squeaksource.com/DPON</a>. It contains a MessageCapture class. I can&#39;t remember exactly how it&#39;s used, but it&#39;s something like:
<br><br>m := MessageCapture captureFrom: anObject forwardTo: aReceiver.<br><br>And then you implement a reciever object which implements some method like &quot;handleMessage: m&quot;. You&#39;ll have to read the source; it&#39;s been hours since I&#39;ve touched this stuff so I can&#39;t remember what the actual methods were.
<br><br>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.<br><br>A message capture can&#39;t easily be stored in a dictionary, because the dictionary calls &quot;hash&quot; on it. As an effect of this, you can&#39;t use them in a workspace. Also, don&#39;t try using an Object Explorer on them. Sometimes alt-. may help, sometimes it won&#39;t.
<br><br>Also, save your code often and keep backups.<br><br>Gulik.<br><br>-- <br><a href="http://people.squeakfoundation.org/person/mikevdg">http://people.squeakfoundation.org/person/mikevdg</a><br><a href="http://gulik.pbwiki.com/">
http://gulik.pbwiki.com/</a>