SE450: Subclassing: How to choose? [7/35] Previous pageContentsNext page

General rule (GoF): prefer delegation.

Main reason: choices can be delayed. Subclassing is fixed at compile time. Delegation can be determined (and changed) at runtime.

Delegation can be difficult when methods are interdependent.

Previous pageContentsNext page