Home > Articles > Software Development & Management > Object Technology
Today, how about we discuss a few items that you're eventually going to need once you've reached the stage of full-blown Airsoft addict. Tactical Load-Bearing Vest or Chest Rig.Not required to play right off the bat, but as you add more and more stuff to your collection of Airsoft stuff, you'll need the vest to help you store that stuff.Stuff like extra mags, two-way radio (aka 'Comms'), maybe. Low End Mac; Miscellaneous Ramblings: Moore Buys a SuperMac - Low End Mac. Reader comments on the iMac/CompuServe bundle, some updated reports. New Resource For REALbasic Programmers Available - The Mac Observer. Macintosh; SoftBook Reader - About This Particular Macintosh; Rocket eBook Pro.
␡- Inheritance
![Ramblings On Realbasic Ebook Store Ramblings On Realbasic Ebook Store](/uploads/1/2/6/2/126272961/107085713.png)
< BackPage 6 of 21Next >
This chapter is from the book REALbasic Cross-Platform Application Development
This chapter is from the book
This chapter is from the book
Inheritance
Now you have a class that implements one method, and you know how to instantiate that class. One of the most powerful features of object-oriented programming is that you organize your classes into conceptual hierarchies, just like you can organize buildings into a conceptual hierarchy. One class can subclass another and when it does this, it inherits the members of the class from which it does the inheriting.
Although you are no doubt familiar with the idea of inheritance, object-oriented inheritance works a little differently than genetic inheritance does. First of all, people have two parents. I'm a mix of my dad and my mom; 50% of my gene pool comes from mom and 50% from dad. (I've often said that I have the distinct pleasure of having inherited all of my parents' worst qualities. In a remarkable reversal of fortune, my daughter has managed to inherit only the finest traits from her parents, mostly from her mom). REALbasic takes a simpler view of inheritance. There's only one parent, which is the superclass. In REALbasic, at the top of the family tree is the root class; Object and all other classes are subclasses of it.
In the object-oriented world, the child is called a subclass and the parent is referred to as the superclass. When you create a subclass in REALbasic, it automatically inherits all the methods and properties of the parent class. There is absolutely no difference other than their name.
Creating a subclass that doesn't do anything differently from the superclass is more or less a pointless exercise. The reason for creating a subclass is that you want to reuse the code you've written for the superclass, and then either add new capabilities or change the way certain things are done.
A child inherits all the features of the parent, but it can also add some new ones. In practice, this means that the subclass has all the methods, constants, and properties of the parent class (with a few exceptions), but it can also implement its own methods, constants, and properties. In this respect, at least, object-oriented inheritance isn't all that much different from the way parent-child relationships work with humans. That's why I always had to set the time on the VCR when I was growing up. My parents didn't know how to do it, but I did. In addition to the methods passed along by the parent, the child can have its own set of methods.
To create a subclass of Alpha in REALbasic, create a class as if it is a new class. Let's name it Beta, which can be done by typing the name into the Properties pane. There are two other properties listed in the pane that we have not discussed yet. After Name comes Interfaces, which I cover later, followed by Super. Setting the value of Super is how you designate this object's superclass, as shown in Figure 3.5. Type in Alpha, and you now have an official subclass of Alpha. It is identical in every way, except that it's called Beta instead of Alpha.
Figure 3.5 Define an object's superclass in the Properties pane.
At this point, the only difference between a and b is their type (or class).
Related Resources
- Book $73.65
- Book $39.99
- eBook (Watermarked) $31.99
Home > Store
Share|
Register your product to gain access to bonus material or receive a coupon.
- By Mark S. Choate
- Published Apr 12, 2006 by Sams. Part of the Developer's Library series.
Book
- Sorry, this book is no longer in print.
Description
- Copyright 2006
- Dimensions: 7' x 9'
- Pages: 672
- Edition: 1st
- Book
- ISBN-10: 0-672-32813-5
- ISBN-13: 978-0-672-32813-8
REALbasic Cross-Platform Application Development treats REALbasic as a serious development environment and is targeted to developers with a minimum of programming experience, but who may or may not be new to the REALbasic platform. Written by a writer and developer with extensive REALbasic experience with input and guidance from REAL Software, this book will show you how to take advantage of the new cross-platform abilities of REALbasic and teach you how to create cross-platform applications. Don't waste any more time with the other novice-oriented REALbasic books out there. Get inside this development environment with REALbasic Cross-Platform Application Development.
Sample Content
Online Sample Chapters
Downloadable Sample Chapter
Table of Contents
Introduction 1
1 Introduction to REALBasic 5
![Store Store](http://i1271.photobucket.com/albums/jj626/OldSanta/Album%203/HowtoMakeMoneywithYouTube_zps54a2c352.jpg)
2 Programming with REALbasic 11
3 Classes and Objects 83
4 Cross-Platform Application Development 143
5 Designing a Desktop Application 213
6 XML and Advanced Text Processing 321
7 Console Programming and the Shell 407
8 Databases451
9 Networking and Internet Programming 489
10 Graphics 533
11 Scripting and Txtending REALbasic 571
A Appendix 597
Index 615
More Information
Other Things You Might Like
- Book $73.65
- Book $39.99
- eBook (Watermarked) $31.99