On 3/6/06, Theodore H. Smith <[EMAIL PROTECTED]> wrote: > > There is this new class I'm making. Let's say its called "SuperSearch". > > It has some methods, that only make sense if called during an event. > > Let's say I have the method "LengthySearch". LengthySearch calls an > event in the subclasses, to pass back collected data. Let's say the > event is "HeresAFoundItem(Item as Item)". > > Now let's say that at this point, where a found item is returned, the > subclass may want to find information on how the item was found. It > might be something like method "WhereWasTheItemFound". > > The thing is, method "WhereWasTheItemFound() as string" has no > meaning, if not called from within the event "HeresAFoundItem". > > How to manage this?
I would introduce a separate class or interface that you can pass an instance of into the event. This makes it easy to manage how it gets called -- the user has to have an instance to call the method on. That would be the easiest, cleanest solution I can think of. Sort of a "context" object, in the case of searching. Beyond that, you could always raise an exception if called at an inappropriate time. HTH, Jon -- Jonathan Johnson REAL Software, Inc. REAL World 2006, The REALbasic User's Conference <http://www.realsoftware.com/realworld> _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives of this list here: <http://support.realsoftware.com/listarchives/lists.html>
