Is mixin considered a design pattern?

蹲街弑〆低调 提交于 2019-12-06 19:12:26

问题


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.



来源:https://stackoverflow.com/questions/543262/is-mixin-considered-a-design-pattern

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!