Understanding Object Oriented Programming
1.....In OOP we create and use objects.
2.....Each object is an instance (created entity ) of a specific class.
3.....Many classes already exist and many more are being developed each day.
4.....Each class has characteristics and capabilities.
5.....Characteristics can be viewed as the physical features that all objects of
the class will take on.
6.....Capabilities can be viewed as actions that all objects of the class will
be capable of doing.
7.....Since hundreds of these classes already exist, programmers do not need to
reinvent the wheel
every time they want to write a program.
8.....Programmers still use the primitive data types and the standard logic and
control structures of
a specific language but now they have
access to a big collection of items (classes) that a already do
things for them.
9.....The key is is learn how to incorporate these new classes into a program to
facilitate the overall
programming task.
10...The following general guidelines are not all encompassing by any
means but they can be viewed as
a very good starting point.
11...Create an object of an existing class or of a class of your own creation.
-- using the "new" keyword
12...This means that the physical feature (instance variables) have been
created and you are ready
to give them values and use the
capabilities (methods) that have already been provided for that class.
13...Using a method on an object of a class is normally pretty simple
>> object_name.method
14...I t now gets a little more complicated because in
order use use objects and methods properly
and in more sophisticated applications, a
programmer needs to thoroughly understand about parameters
and returned values.
15...The above is critical because many aspects of object oriented programming
involve
"objects
communicating with each other"
16...Objects basically send and receive messages
(values, references etc.) back and forth.
EXAMPLE
String name = person.substring(1,20);
17...In the above, the substring method is called on the person object and it is
passed 2 parameters. These
parameters are needed by the method.
18...The method in the above is a NON void method because it RETURNS a String
value. And in this example
the value is assigned to another
String object.called name.
19....This concept of objects communicating by passing values back and forth is
critical to understanding OOP..
20....You can create your own classes and provide methods that allow the outside
world to have access to
your instance variables or use
existing classes and their methods. Either way, you create objects of the
respective class and you can
use their methods on your new object. You also have the right to override
methods not quite suited to
your specific task. Bottom line is "you must know how to use the methods
and handle what they give you
back -- NO SURPRISES".