This post originated from an RSS feed registered with Agile Buzz
by James Robertson.
Original Post: Speaking of dangerous power
Feed Title: Cincom Smalltalk Blog - Smalltalk with Rants
Feed URL: http://www.cincomsmalltalk.com/rssBlog/rssBlogView.xml
Feed Description: James Robertson comments on Cincom Smalltalk, the Smalltalk development community, and IT trends and issues in general.
I was talking about dangerous power in this post, and I got an email comment on another doozy you can get enamored of - #doesNotUnderstand:
The first time you realize that you can implement #doesNotUnderstand: in your own classes (or in any class), it can lead to some truly dangerous (and hard to follow) Smalltalk code. Here's an example - something I used to do a lot of when I first learned Smalltalk:
The intent here is to handle an inbound event (sent via dependency) - and let events we get (but don't care about) fall on the floor. Why is this dangerous? Well, notice that the "let the events we don't care about fall" mechanism is a MessageNotUnderstood handler. That means that if any MNU is raised downstream from the #perform: (i.e., not in trying to perform the event, but in trying to handle it) - it will get swallowed. This leads to errors that are nearly impossible to diagnose (trust me - I've written myself into this corner). In general, you want to think twice (or more!) before you decide to handle an MNU in "normal" code....