Object oriented concepts
- 2. What is an object?
An object is a software entity that mirrors the real
world in some way.
A software object in OOP has data (the attributes) and
code that responds to instructions. Think of the code
and data as being welded together --the code
completely wrapping the data in a shell to protect it
from the hostile outside world." [Franz]
2
- 3. What is an object?
(Continued)
”An object has state, behavior, and identity;
[Booch 91]
“An object is an encapsulation of state (data
values) and behavior (operations). Thus an
object is in many ways similar to a module, or
an abstract data type." [Budd]
3
- 4. Procedural languages vs Objectoriented languages?
Procedural languages (Pascal, C, Fortran,
etc.) operate on data a step at a time. A
program written in one of these languages has
two components:
data
(variables and records)
code (instructions that act on the data and do the
work).
There is a rigid separation of code from data.
4
- 5. PRO-Lang vs OO-Lang
(Continued)
An object-oriented language breaks a
program into hundreds of tiny entities that
have small bits of code and data fused tightly
together. Where subroutines are a
convenience in a procedural language, the
separateness of these entities is essential to an
object-oriented program.
5
- 6. OBJECT-ORIENTATION - A NEW
PARADIGM
Object-oriented programming is a new
programming paradigm (a new way of
viewing the world).
The underlying ideas of the object-oriented
technique are the same basic methods humans
use to solve problems in the world (e.g.,
abstraction).
6
- 7. OO A NEW PARADIGM
(Continued)
Computer novices and children grasp the
ideas of OOP easier than computer
professionals. The professionals require a
paradigm shift which is very difficult (due to
preconceived notions) whereas the children
don't.
7
- 8. TERMS:
Object: A software entity that mirrors the
real world in some way. Everything in an
object-oriented programming language is an
object.
Class: A class is a template from which
objects are created (i.e., a blueprint for the
objects it defines). Every object made from a
class is the same as every other.
8
- 9. TERMS:
(Continued)
Instance: Instances are the individual
objects created by a class. Every object is an
instance of a class.
Related Term:
Instantiation: Creating a new (specific)
object from a general class is called
instantiation.
9
- 10. TERMS:
(Continued)
Method: The behavior of a class, and all its
instances, is described by a method.
Methods are like procedures:
They execute step-by-step,
Can do branching and looping,
Take arguments,
Have local variables,
Return values (objects).
10
- 11. TERMS:
(Continued)
Methods are unlike procedures:
they may only access data of the class for which they
are defined, an instance's data can only be accessed
through
its class' method.
Note: A class' methods completely
encapsulate the data of objects of the class for
which they are defined.
11
- 12. TERMS:
(Continued)
Message: A request to a specific instance,
called the receiver, to invoke a specific
method. Along with the name of the method,
(the selector) additional information
(arguments, i.e., objects) can be passed as
part of the message.
12
- 13. TERMS:
(Continued)
When the object receives the message, it
invokes the method for the selector. This can:
(1) change the object's instance variables,
(2) send another object back as a direct
response to the message,
(3) do something in the real world of the
computer, such as display information, print a
message, or read a block of data from a file.
Much of the code within methods consists
of passing messages to other objects.
13
- 14. TERMS:
(Continued)
Abstraction: A problem solving
tool that allows one to think of a
problem at a higher level without
worrying about the details.
Abstraction refers to organizing
information based on three
abstraction mechanisms:
classification, generalization,
and aggregation.
14
- 15. ABSTRACTION MECHANISMS
(Continued)
Classification forms new objects by
suppressing the details of individual
instances and emphasizing properties of the
whole. New object types (classes) are
formed by collecting instances.
Classification = set theoretic operation 'membership'
==> describes the 'instance-of' relationship
15
- 20. ABSTRACTION MECHANISMS
(Continued)
Aggregation forms an object as a relationship
among other objects. It suppresses the details
of the components and emphasizes the details
of the relationship as a whole.
Aggregation = set theoretic operation
'cartesian product'
==> describes the 'is-part-of‘ relationship
20
- 21. ABSTRACTION MECHANISMS
(Continued)
EX: Consider object types 'stove',
'refrigerator', 'sink', 'cabinet'. A 'kitchen'
object can be abstracted from the given
objects. The individual objects (e.g., 'stove')
are components of the aggregate ('kitchen').
21
- 24. TERMS:
(Continued)
Information hiding as defined by Parnas [Par72]
suggests decomposing systems into components that
hide or encapsulate design decisions about
abstractions.
Data abstraction refers to defining data types in
terms of the operations that apply to objects of the
type, with the constraint that the values of such
objects can be modified and observed only by the use
of the operations [Oxf86].
24
- 25. TERMS:
(Continued)
Data abstraction is thinking in terms of what
you can do to a collection of data
independently of how you do it.
Related term:
Abstract data type (ADT) is a collection of
data structured in a particular fashion
together with a set of operations that
manipulate the data.
25
- 26. TERMS:
(Continued)
Inheritance: The principle of receiving
properties or characteristics from an ancestor
and is used to define new data types as
extensions or restrictions of existing types.
Polymorphism and dynamic binding:
Program entities should be permitted to refer
to objects of more than one class, and
operations should be permitted to have
different realizations in different classes.
26
- 27. TERMS:
(Continued)
o
o
Polymorphism: refers to the situation
whereby a given program entity may refer at
run-time to instances of different classes.
Dynamic binding: refers to the situation
whereby the run-time system will
automatically select the version of an
operation adapted to the corresponding
instance.
27