|
|
| |
1. traits are not multiple inheritance |
|
Reply |
|
|
 Stefan Jibrail Froelich | 2011-08-02 20:03:11 |
Traits are more like mixins which allow us to achieve horizontal code reuse. This allows us to respect the DRY principle while allowing combinations of functionality easily. Imagine trying to build classes from permutations of BouncingBall, ColoredBall, FlyingBall and RollingBall. Or adding a persist method to User and Book without duplicating code.
A quick google of horizontal inheritance will give you loads of examples. |
| |
2. Re: traits are not multiple inheritance |
|
Reply |
|
|
 Manuel Lemos | 2011-08-06 07:04:33 - In reply to message 1 from Stefan Jibrail Froelich |
| Ernani did not said traits are multiple inheritance, he just said it would be a way to achieve similar type of code reuse for those familiar with multiple inheritance. |
| |
3. Re: traits are not multiple inheritance |
|
Reply |
|
|
 Stefan Jibrail Froelich | 2011-08-06 19:23:33 - In reply to message 1 from Stefan Jibrail Froelich |
'...it seems to be similar to inheritance, multiple inheritance, in a different way...'.
I wanted to point out that though it might seem that way, it shouldnt be confused with vertical inheritance.
Believe me, many of us follow this cast (i cant wait for the next one) and your words are like gold to us. Some newbie might take it as is. Thanks for the best repository by the way. |
|