Page 9 - DCAP308_OBJECT_ORIENTED_ANALYSIS_AND_DESIGN
P. 9
Unit 1: Introduction to Object Orientation
A class or object class is a group of objects with similar properties (attributes), common Notes
behavior (operations), common relationships to other objects, and common semantics. A
class is a definitive description of a group of objects with similar properties and behaviors.
Classes are abstract, objects are concrete. Objects are aware of their class identity. Each
instance (object) of a class has a unique identity and its own set of values for its attributes.
Objects within a class share a common semantic purpose above and beyond requirements
of common attributes and behavior. The grouping of objects into classes abstracts a problem,
that is, classes provide logical groupings of entities in a system. Individual objects within
a class maintain their distinct identity.
Object References: In a program, you identify and address objects using unique object
references. Object references allow you to access the attributes and methods of an object.
Identity: Identity means that data is quantized into discrete, distinguishable entities called
objects. An object is a section of source code that contains data and provides services. Each
object has its own inherent identity. In other words, two objects are distinct even if all
their attribute values are identical.
Example: Name and size are the examples of attribute values.
In the real world an object simply exists, but within a programming language each object
has a unique handle by which it can be referenced. Languages implement the handle in
various ways such as an address, array index, or artificial number. Such object references
are uniform and independent of the contents of the objects, permitting mixed collections
of objects to be created, such as a file system directory that contains both files and sub-
directories.
Classification: Classification means that objects with the same data structure (attributes)
and behavior (operations) are grouped into a class.
Example: Paragraph, Monitor, and ChessPiece are examples of classes.
A class is an abstraction that describes properties important to an application and ignores
the rest. Any choice of classes is arbitrary and depends on the application.
Each class describes a possibly infinite set of individual objects. Each object is said to be an
instance of its class. An object has its own value for each attribute but shares the attribute
names and operations with other instances of the class. An object contains an implicit
reference to its own class; it “knows what kind of thing it is.”
Polymorphism: Identical (identically-named) methods behave differently in different
classes. Object-oriented programming contains constructions called interfaces. They enable
you to address methods with the same name in different objects. Although the form of
address is always the same, the implementation of the method is specific to a particular
class.
Polymorphism is the kindred to the incorporation of data and behavior. The same operation
may apply to many different classes, with some classes having distinct behavior
(implementation). Such an object is polymorphic.
Example: A “draw” operation has different implementations for the classes circle, square,
and polygon.
An operation is simply an abstraction of analogous behavior across different kinds of
objects.
LOVELY PROFESSIONAL UNIVERSITY 3