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. Thanks, Chad |
>>>>> "cnantais" == cnantais <[hidden email]> writes:
cnantais> Can someone recommend a good read on how to use proxy objects in cnantais> Smalltalk? cnantais> I'm trying to verify expectations about the messages that classes cnantais> are receiving (as is done in rSpec, the Ruby BDD framework) and I cnantais> think proxy objects may be the right pattern. See the ObjectTracer class under "Kernel-Objects". Here's the class comment: An ObjectTracer can be wrapped around another object, and then give you a chance to inspect it whenever it receives messages from the outside. For instance... (ObjectTracer on: Display) flash: (50@50 extent: 50@50) will give control to a debugger just before the message flash is sent. Obviously this facility can be embellished in many useful ways. See also the even more perverse subclass, ObjectViewer, and its example. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 <[hidden email]> <URL:http://www.stonehenge.com/merlyn/> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by cnantais
On Jan 11, 2008 12:19 PM, cnantais <[hidden email]> wrote:
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/ _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Free forum by Nabble | Edit this page |