Alan Kay summarized five basic characteristics of Smalltalk, the first
successful object-oriented language and one of the languages upon which Java
is based. This represents a pure approach to object-oriented programming:
1. Everything is an object. Think of an object as a fancy variable: it stores
data, but you can also ask it to perform operations on itself by making
requests. In theory, you can take any conceptual component in the problem
youre trying to solve (dogs, buildings, services, etc.) and represent it as
an object in your program.
2. A program is a bunch of objects telling each other what to do by sending
messages. To make a request of an object, you send a message to that object.
More concretely, you can think of a message as a request to call a function
for a particular object.
3. Each object has its own memory made up of other objects. Or, you make a new
kind of object by making a package containing existing objects. Thus, you can
build up complexity in a program while hiding it behind the simplicity of
objects.
4. Every object has a type. Using the parlance, each object is an instance of
a class, where class is synonymous with type. The most important
distinguishing characteristic of a class is what messages can you send to it?
�
5. All objects of a particular type can receive the same messages. This is
actually a very loaded statement, as you will see later: because an object of
type circle is also an object of type shape, a circle is guaranteed to receive
shape messages. This means you can write code that talks to shapes, and
automatically handle anything that fits the description of a shape. This
substitutability is one of the most powerful concepts in OOP.
Some language designers have decided that object-oriented programming itself
is not adequate to easily solve all programming problems, and advocate the
combination of various approaches into multiparadigm programming languages 2 .