From: Robert Klemme Date: 2005-09-21T01:46:40+09:00 Subject: Re: Interesting class christophe.poucet@gmail.com wrote: > Dear, > > Though mixins are a very nice alternative for multiple inheritance, > they do sometimes cause name crashes that are quite annoying. In a > recent project I was working on, a design choice I made is that > everything would be destroyed with the method 'teardown'. What I mean > is that connections are closed, files are closed, etc etc.. As I was > refactoring the code, I noticed two pieces of code that could each be > put into their own module (factored out). However this led to the > fact that both the class that included the module as well as the > super class of that class and the class itself had the method > teardown. I could've chosen to rename the method inside the > extracted module, but instead I came up with quite an interesting and > reusable pattern. > > The idea is that if you have a module with certain methods, you rename > those methods to modulenameinlowercase_methodname in the module. It > is important that for this to work, the module must be included in the > class after any methods with similar names have been defined. > (Preferably at the end of the class). Wouldn't it be simpler to do class Object def teardown() end end and in each module and class module Foo def teardown # local cleanup super end end ? Kind regards robert