This shows you the differences between two versions of the page.
|
en:techniques:programming:object-oriented:inheritance:traits [2012/04/15 00:42] marielle |
en:techniques:programming:object-oriented:inheritance:traits [2012/04/15 00:43] (current) marielle |
||
|---|---|---|---|
| Line 157: | Line 157: | ||
| ==== Traits vs Multiple Inheritance ==== | ==== Traits vs Multiple Inheritance ==== | ||
| + | |||
| + | Difficulties experienced with multiple inheritance disappear with traits, because traits are divorced from the inheritance hierarchy. | ||
| + | |||
| + | (source: [[http://scg.unibe.ch/archive/papers/Duca06bTOPLASTraits.pdf|Traits: A Mechanism for Fine-grained Reuse]], PDF) | ||
| At a first glance, trait composition is very similar to multi- ple inheritance. Both approaches allow one to reuse function- ality from more than one source at the same time, which has the benefit of better code reuse and allows more flexible class hierarchies. Nevertheless, there are essential differences: | At a first glance, trait composition is very similar to multi- ple inheritance. Both approaches allow one to reuse function- ality from more than one source at the same time, which has the benefit of better code reuse and allows more flexible class hierarchies. Nevertheless, there are essential differences: | ||