You are on page 1of 22

UNIT- I

DAY- 1
-K. Indhu
GOALS
• Define Objects
• Define Classes

• Describe Object’s
– Methods,
– Attributes

• Difference between Object Oriented Approach


& Traditional programming approach.

13-DEC-13 K. INDHU 2
WHAT IS AN OBJECT?
• In an object-oriented system, everything is an
object:-
• numbers,
• arrays,
• records,
• fields,
• files,
• forms,
• an invoice, etc.

13-DEC-13 K. INDHU 3
WHAT IS AN OBJECT?
• Tangible Things as a car, printer, ...
• Roles as employee, boss, ...
• Incidents as flight, overflow, ...
• Interactions as contract, sale, ...
• Specifications as colour, shape, …

13-DEC-13 K. INDHU 4
FINALLY… DEFINITION OF OBJECT
• An object represents an individual, identifiable
item, unit, or entity,
– either real or abstract, with a well-defined role in
the problem domain
– about which we store data
– and those methods that manipulate the data.

• Conceptually, each object is responsible for


itself.

13-DEC-13 K. INDHU 5
WHY DO WE CARE ABOUT OBJECTS?
• Modularity - large software projects can be
split up in smaller pieces.
• Reuseability - Programs can be assembled
from pre-written software components.
• Extensibility - New software components can
be written or developed from existing ones.

13-DEC-13 K. INDHU 6
ABOUT OBJECTS
Object = Data + Methods
or to say the same differently:

An object has the responsibility to know and the


responsibility to do.

13-DEC-13 K. INDHU 7
ABOUT OBJECTS
• The term object was first formally utilized in
the Simula language to simulate some aspect
of reality.

• An object is an entity.
• – It knows things (has attributes)
• – It does things (provides services or has
methods)

13-DEC-13 K. INDHU 8
ABOUT OBJECTS

13-DEC-13 K. INDHU 9
ABOUT OBJECTS

13-DEC-13 K. INDHU 10
ABOUT OBJECTS

13-DEC-13 K. INDHU 11
ABOUT OBJECTS

13-DEC-13 K. INDHU 12
ABOUT OBJECTS

13-DEC-13 K. INDHU 13
ABOUT OBJECTS

13-DEC-13 K. INDHU 14
ABOUT OBJECTS
• Attributes (or) properties
describe object’s state
[data] and methods define
it’s behavior [or it’s
operations].

13-DEC-13 K. INDHU 15
C++ CODE- ATTRIBUTES & METHODS
#include<string>
#include<iostream>
class Person{
PRIVATE
char name[20];
DATA
int yearOfBirth;
public:
void displayDetails() { PUBLIC
cout << name << " born in " PROCESSES
<< yearOfBirth << endl;
}
//...
};

13-DEC-13 K. INDHU 16
OBJECT’S ATTRIBUTES
• Attributes represented by data-type.
• They describe objects states.
• In the Car example the car’s attributes are:-
– color,
– manufacturer,
– cost,
– owner,
– model, etc.

13-DEC-13 K. INDHU 17
CLASS
• Class is a user-defined data type which is also called
as the Template.
• It is the blue-print of the Objects.
• DEFINITION OF CLASS:-
• Class refers to a template for a group of
individual objects with common attributes and
common behavior.
•The difference between an Object and a Class is that
the class defines shared attributes and behaviors of
objects
•An object is an instance or occurrence of a class.

13-DEC-13 K. INDHU 18
CLASS

13-DEC-13 K. INDHU 19
DIFFERENCE BETWEEN TRADITIONAL
APPROACH & OBJECT ORIENTED
APPROACH
• Traditionally development methodologies are
algorithmic centric-
• build the algorithm then design the data structure

• Object oriented methodologies are Data centric-


• structure the data and build the algorithm

13-DEC-13 K. INDHU 20
DIFFERENCE BETWEEN TRADITIONAL
APPROACH & OBJECT ORIENTED
APPROACH
• The traditional approach to software development
tends toward writing a lot of code to do all the things
that have to be done.
• You are the only active entity and the code is just
basically a lot of building materials.
• OO approach is more like creating a lot of helpers
that take on an active role, a spirit, that form a
community whose interactions become the
application.

13-DEC-13 K. INDHU 21
HAPPY LEARNING!!!

You might also like