Old Articles‎ > ‎

Inheritance v/s Containment

Points to ponder:

Containment is Object composition whereas Inheritance is Class composition.Containment is more a relation between instances whereas Inheritance is more a relationship between classes. Not all languages support both these features. Languages which support only containment are Object based programming languages. Languages that support class composition are Object Oriented programming languages.
Both the concepts promote the re-usability principle but in different aspects and having different implications.Containment exhibits Has-A relation whereas Inheritance exhibits IS-A relationship.With protected field access and overloading Inheritance is suitable to extend an server from an existing server. 
Containment gives implementation reuse whereas Inheritance gives reusable implementation as well as interface reuse.  Interface reuse results in contractual consistency in the base and extension services.