CSC/ECE 517 Fall 2012/ch1 1w17 ir

From Expertiza_Wiki
Revision as of 19:52, 8 September 2012 by Ikjaishw (talk | contribs) (→‎Ruby)
Jump to navigation Jump to search

Extending Objects


The ‘extend’ feature in computer programming languages allow the programmer to dynamically extend the functionality of an object at runtime, as opposed to extending functionality at compile time. This feature can be found in Object Oriented Programming (OOP) Languages.

Introduction

The programming paradigm OOP uses 'objects' for designing applications. These objects consist of an encapsulated set of data fields and methods, and are usually an instance of a class. These objects can communicate with each other through messages (or 'methods') and process data in object oriented programming. But in order to increase an object's functionality, it is necessary to add the features of one object to another. This can be done dynamically at run time, without repeating the code, by extending the features of one class to another. This can be done by the use of the 'extend' keyword. Many OOP oriented languages support the 'extend' feature.

An object is an entity that serves as a container for data and also controls access to the data. Associated with an object is a set of attributes, which are essentially no more than variables belonging to that object. Also associated with an object is a set of functions that provide an interface to the functionality of the object, called methods. - Hal Fulton[2]

Languages Using 'extend' Functionality

C++

Example Code Snippet

Java

Example Code Snippet

Ruby

Ruby is a OOP language. It differs from the previous two OOP languages mentioned above in how it interprets what 'object-oriented' means and the different terminologies for the concepts it employs.

A class hierarchy in Ruby [1]

Example Code Snippet

Python

Example Code Snippet

Advantages

Disadvantages

Conclusion

See also

References

<references/>

Further Reading

External Links