Daniel Gronau

Greenhorn
+ Follow
since Oct 06, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Daniel Gronau

Traits are like abstract classes, because you can have abstract or concrete methods. On the other hand traits are like interfaces, because they have no constructors, and a class can extend/implement more than one trait, which gives a limited form of "multiple inheritence" (behind the scene it is still single inheritance by a linearization process), but without many of the problems (like the diamond problem). Traits are not a new invention, they are used in other languages as well, but often under the name "Mix-in".

Traits are very flexible and can be used in several pattern, which are not possible with abstract classes and/or interfaces, see e.g. http://www.artima.com/scalazine/articles/selfless_trait_pattern.html or http://www.artima.com/scalazine/articles/stackable_trait_pattern.html

14 years ago