From: Dave Thomas Date: 2001-01-10T12:35:09+09:00 Subject: [ruby-talk:8977] Re: Modules and mixins Kevin Smith writes: > Bingo. Typical aggregation would allow you to insert, say, a Logger > object member into each of your classes. But what if you want to > actually insert a handful of methods? Or a couple data members and > some methods? Mixins allow you to do that and those inserted items > are part of your class itself, rather than you having to remember > that they're part of an aggregated member. Just to back up what Kevin says: Mixins are also not just passive. They can alter the class that includes them (which is half way to Aspect Oriented Programming). For example, the Singleton mixin prevents you from creating instances of classes that include it. In the logging case, you could write a logging mixin which intercepted calls to every method in classes that used it, printing their parameters. Mixins are far more than passive aggregation. Regards Dave