June 2017
Intermediate to advanced
873 pages
18h 9m
English
In object-oriented languages, it is useful to build on one class to create a more specialized related class. For example, in the text editor, the base dialog class was extended to create an alert and confirm pop ups. What if we want to share some functionality but do not want inheritance occurring between the classes?
Aggregation can solve this problem to some extent:
class A {
classb usefulObject;
}The downside is that this requires a longer reference to use:
new A().usefulObject.handyMethod();
This problem has been solved in Dart (and other languages) by having a mixin class do this job, allowing the sharing of functionality without forced inheritance or clunky aggregation.
In Dart, a mixin must meet the following requirements:
Read now
Unlock full access