a class is based on another class « Is a » relationship • Composition : one object containing another one « Has a » relationship • Aggregation : one object using another one « Uses a » relationship
Wikipedia says « Composition is where a structure directly includes its members, whereas Aggregation is where a structure only contains references to those members. » • In Ruby everything is object, so Aggregation is the same as Composition. • For C++ fans, just a * difference
Wikipedia « An object, instead of performing one of its stated tasks, delegates that task to an associated helper object. » • Forwarding ? Nothing on Wikipedia but in Delegation page « this mechanism is sometimes referred to as forwarding » :) • DELEGATION = FORWARDING … semantically
inheritance » The Gang of Four • More reusable, more flexible, better testability • A first guideline, « has a » composition, « is a » inheritance • But Liskov Substitution Principle seems to be more accurate
Secrets of the Standard Library with SimpleDelegator, Forwardable and more. • Re-use in OO: Inheritance, Composition and Mixins • Inheritance Vs. Composition