Reputation: 1280
What's is the difference between mixin and extend, when to use each one?
Upvotes: 25
Views: 7886
Reputation: 1510
A mixin is a special kind of multiple inheritance. There are two main situations where mixins are used:
Upvotes: 3
Reputation: 3281
I wrote this article about Ember.Object which explains the differences in detail. Essentially, use extend
to create a new class from a base class and use mixins to separate lateral concerns that you may want to include in any number of classes / objects. Mixins can be included in classes via extend
or objects via create
.
Upvotes: 34