CSC/ECE 517 Fall 2007/wiki2 10 ab: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
Line 5: Line 5:
Inheritance vs. delegation. Follow the debate on inheritance vs. delegation. Construct (or, better, cite) examples that show cases where inheritance is better, and cases where delegation is better. Attempt to characterize the situations in which you should employ one or the other.
Inheritance vs. delegation. Follow the debate on inheritance vs. delegation. Construct (or, better, cite) examples that show cases where inheritance is better, and cases where delegation is better. Attempt to characterize the situations in which you should employ one or the other.
==What is Inheritance==
==What is Inheritance==
Inheritance in the concept of Object Oriented Programming is the process by which one object can inherit or acquire the properties of other objects. With the use of inheritance each object which are instances of derived classes can only define the properties which are unique to itself and derive qualities or common attributes from other objects which are instances of base classes To cite this as an example, consider this page [http://www.eecs.utoledo.edu/~ledgard/oop/page2h.html "Real life Inheritance Examples"]. If we consider the first example it can be seen that the base class in this case is a bank account which contains properties like Name, SSNnum, Account No and Balance. The checking and savings account derive these properties by inhering from the BankAccount class and hence these classes do not need to explicitly define these characteristics all over again. The obvious advantages of inheritance is reusability which greatly reduces code repetition .  
Inheritance in the concept of Object Oriented Programming is the process by which one object can inherit or acquire the properties of other objects. With the use of inheritance each object which are instances of derived classes can only define the properties which are unique to itself and derive qualities or common attributes from other objects which are instances of base classes .The obvious advantages of inheritance is reusability which greatly reduces code repetition. Inheritance is directly supported by object oriented languages and it gives way to the concept of polymorphism. The inheritance relationship between the base and derived classes is illustrated at compile time which means that a class cannot change its parent class dynamically at run-time.
 


==What is Delegation==
==What is Delegation==

Revision as of 16:49, 23 October 2007

Problem Statement

Inheritance vs. delegation. Follow the debate on inheritance vs. delegation. Construct (or, better, cite) examples that show cases where inheritance is better, and cases where delegation is better. Attempt to characterize the situations in which you should employ one or the other.

What is Inheritance

Inheritance in the concept of Object Oriented Programming is the process by which one object can inherit or acquire the properties of other objects. With the use of inheritance each object which are instances of derived classes can only define the properties which are unique to itself and derive qualities or common attributes from other objects which are instances of base classes .The obvious advantages of inheritance is reusability which greatly reduces code repetition. Inheritance is directly supported by object oriented languages and it gives way to the concept of polymorphism. The inheritance relationship between the base and derived classes is illustrated at compile time which means that a class cannot change its parent class dynamically at run-time.

What is Delegation

Delegation, in the concept of object oriented programming refers to the ability of an object in assigning or delegating the implementation of certain functions to other objects. This concept is also referred to as dynamic inheritance. A good example of the concept of delegation is given here "Example of Delegation"

Inheritance or Delegation

References