Decorating Classes with Multiple Mixins
When we mix in multiple classes, all of those classes’ methods are available in the target class. By default, methods hide on collision. That is, if two or more classes being mixed in have methods with the same name and parameters’ signature, the method in the latest-added mixin hides the method that has already been injected.
We can program these methods to instead collaborate in a way that the call can result in a chain of methods calls. Let’s create a chain of filters to transform the parameters they receive; we’ll see how mixins can provide such a design option.
An application needs different types of writers; the target may be a file, a socket, a web service, a simple string, and so on. We’ve generalized ...