CSC/ECE 517 Fall 2012/ch1 1w17 ir: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
Line 16: Line 16:
===Ruby===
===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.  
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.  
[[File:rubyclass.jpg|thumb|250px|Group of precious and semiprecious stones —both uncut and faceted— including (''clockwise from top left'') [[diamond]], uncut [[sapphire]], [[ruby]], uncut [[emerald]], and uncut [[amethyst]].]][http://rubylearning.com/satishtalim/writing_our_own_class_in_ruby.html]
[[File:rubyclass.jpg|thumb|500px|A class hierarchy in Ruby]][http://rubylearning.com/satishtalim/writing_our_own_class_in_ruby.html]


====Example Code Snippet====
====Example Code Snippet====

Revision as of 19:52, 8 September 2012

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[1]

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

[2]

Example Code Snippet

Python

Example Code Snippet

Advantages

Disadvantages

Conclusion

See also

References

<references/>

Further Reading

External Links