CSC/ECE 517 Summer 2008/wiki2 8 Inh-Del

From Expertiza_Wiki
Revision as of 02:37, 22 June 2008 by Abhuwan (talk | contribs)
Jump to navigation Jump to search

Inheritance vs Delagation

Inheritance and delegation plays a very important role in object-oriented languages.Both of the technique prevent the user to write the same code again and again in the program.

Inheritance

Hierarchical code structure, which keep most of the common code at the top most hierarchy ,is called inheritance.The top most class is called as the parent class, base class or a superclass.The classes derived from the parent class are known as child classes or subclasses.The code can be reused up to lower levels of the hierarchy. Classes get more specialized as you move toward the bottom of the hierarchy.

Delegation

A technique,which provides the functionality of implementation of a particular interface to a field or expression is called delegation.Delegation passes a duty off to someone else.It can be define in terms of objects ,where one object forwards  certain fuction calls to another object, called its delegate. Delegation is a very powerful reuse technique.