Article Preview
Buy Now
| Print: | |
| PDF: |
Object-Oriented Thinking
Pondering Polymorphism
Issue: 4.2 (November/December 2005)
Author: Charles Yeomans
Article Description: No description available.
Article Length (in bytes): 4,633
Starting Page Number: 33
RBD Number: 4215
Resource File(s): None
Related Web Link(s):
http://www.declareSub.com/
Known Limitations: None
Excerpt of article text...
Polymorphism is perhaps the most elusive of the fundamental concepts of object-oriented programming. Perhaps the reason is that it's often poorly explained. What I think of as the standard mistake of exposition is to explain polymorphism in terms of the ability to override methods in subclasses. This is not polymorphism; this is a way to implement polymorphism. In many previous columns I have demonstrated polymorphism in action. Here I take my crack at putting forth my understanding of polymorphism.
Object Types and Polymorphism
In REALbasic, an object type is a description of what an object can do. In particular, a type specification is a list of the public methods and properties of an object. An object comes with a default type -- the set of all public methods and properties of its class. However, an object can have more than one type.
If the object's class inherits from another class, the object also inherits the associated type of the superclass. Thus an EditField also has types RectControl and Control. Also, all classes other than Object inherit from Object, so every object in REALbasic has type Object.
...End of Excerpt. Please purchase the magazine to read the full article.
Article copyrighted by REALbasic Developer magazine. All rights reserved.
|










