Here's my quick lesson on object oriented programming for RPG
First think of an object as a data structure. A class is a template for
the data structure with a bunch of functions and sub-procedures that
work on that data structure (and that data structure only).
When you instantiate an object from a class, you create a new copy of
that data structure in memory. Any time you refererence that new object,
you can work on it only with methods (procedures ) from the class.
When you subclass a class, you get a template of the original data
structure and an additional data structure for fields that belong only
to the subclass.
When you upcast a class to its parent class, you say to the compiler
"I'm only going to use the data structure and methods of the parent
class", even though that extra stuff is there.
There are a few confusions to this view, but that's pretty much the nut
of it. The biggest wrinkle is that methods of the parent class can be
overridden in the subclass, in which case the method from the subclass
would be used even though you were referring to the object by the parent
class. This is a pretty powerful wrinkle -- polymorphism.
In your example Student is a subclass of Person. A Student "does" all
the things a person does, but does some of them a little differently and
has some of it's own little quirks.
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Dan
Sent: Wednesday, October 28, 2009 5:23 PM
To: Midrange Systems Technical Discussion
Subject: ITCAP exam for "Beginning Java Programming"
Anyone taken this?
I am taking a week-long course that covers a 390-page course book and
will be taking the ITCAP certification exam on Friday afternoon. I
don't know if "Beginning Java Programming" is the actual name of the
exam, but the course is supposed to get us to where we can pass it.
While the "certification" is a nice acknowlegement, passing the exam is
crucial since the cost will be covered by the corporation's general
"educational" funds, as opposed to my department's disbursement code if
I don't pass the exam.
The instructor indicated that the exam normally takes about 15 minutes
to complete. It occurs to me, then, that we are covering a whole lot
more material in 35 hours than we will be tested on.
My weak spots are in some fundamental stuff like casting, for example:
Person p1 = new Student();
and then using p1. I will be googling for this type of stuff tonight,
but most of what I've found thus far is "technical reference" and not
any "here's why you want to do this".
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at http://archive.midrange.com/midrange-l