CSC/ECE 517 Fall 2011/ch4 4a aj: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 7: Line 7:


     One of the most fundamental advantages of using Object Orientation is to reuse code. Rather than coding what was already  
     One of the most fundamental advantages of using Object Orientation is to reuse code. Rather than coding what was already  
coded, we can simply extend it to suit the needs of the new class. This helps to develop applications rapidly.  
coded, we can simply extend it to suit the needs of the new class. This helps to develop applications rapidly.  
Many languages provide built in libraries which can be included in classes. The O-O languages also provide a way to add
Many languages provide built in libraries which can be included in classes. The O-O languages also provide a way to add
functionality to existing classes through extension.
functionality to existing classes through extension.
=Implementation of Code Reuse:=
=Implementation of Code Reuse:=
“Inheritance” is the word used in O-O for the process of inheriting the members of a class and extending the functionality.  
“Inheritance” is the word used in O-O for the process of inheriting the members of a class and extending the functionality.  
A class can inherit from a single class or “Multiple Classes”, the latter is called as “Multiple Inheritance”.
A class can inherit from a single class or “Multiple Classes”, the latter is called as “Multiple Inheritance”.
While a child class inherits from the parent class,  it tends to inherit all the members of the class.
While a child class inherits from the parent class,  it tends to inherit all the members of the class.


=Comparison of Extend methods in Java, C# and Ruby.=
=Comparison of Extend methods in Java, C# and Ruby.=


'''''In java:'''''
'''''In java:'''''

Revision as of 19:19, 18 October 2011

Extending objects. : Consider one or more practical examples of Ruby's extend method--that is,
examples that serve a real need and are not contrived.  What facilities do other languages have for extending
objects?  Are they more or less powerful than Ruby's?  Also consider prototype-based languages such as Self, 
which don't even provide classes.

Introduction

    One of the most fundamental advantages of using Object Orientation is to reuse code. Rather than coding what was already 
coded, we can simply extend it to suit the needs of the new class. This helps to develop applications rapidly. 
Many languages provide built in libraries which can be included in classes. The O-O languages also provide a way to add
functionality to existing classes through extension.

Implementation of Code Reuse:

“Inheritance” is the word used in O-O for the process of inheriting the members of a class and extending the functionality.

A class can inherit from a single class or “Multiple Classes”, the latter is called as “Multiple Inheritance”.
While a child class inherits from the parent class,  it tends to inherit all the members of the class.

Comparison of Extend methods in Java, C# and Ruby.

In java: