Are mixins considered a design pattern? Structural?
问题:
回答1:
They're a language feature. A "pattern" is different from a feature, in that it resolves a set of forces that may influence a situation in contradictory ways. Features, by their presence or absence, tend to create the forces that patterns resolve. Many design patterns (Double Dispatch is a good example) came about to work around language limitations (in this case method dispatching on a single argument).
回答2:
Yes, it is in Ruby.
Design Patterns in Ruby
回答3:
Yes, it is in D.
"A design pattern is a general reusable solution to a commonly occurring problem in software design" -- Wikipedia
D is compiled to machine code and with the use of mixins you can use it to make templates even more useful than they are in something like C++.
http://www.digitalmars.com/d/1.0/template-mixin.html
回答4:
Mixins are not design patterns. Most of the time they are language features!! E.g. in the language D "mixin" is a keyword. Using a keyword for its intended pupose is no pattern. Typical usages of keywords/language features might be called "idiom"s.
The hierarchie is "nothing", idiom, design pattern, architecture pattern.