Sunteți pe pagina 1din 28

Introduction to

Object Oriented Concepts



Prepared By:
Eng.\ Tarig Ahmed Khalid, M.Sc., PMP, CEC, CBAP


General Features of Programs
Input Output
Processing
Data
Information
a. Logic
+
b. Syntax
Data / Information
Primitive Data Type Abstract Data Type
Numeric
Character
Integral
Real
Classes
1. Classical Programming.
2. Structured Programming.
3. Object Oriented Programming.
Evolution of Programming Techniques
Input x,y,z
..
..
If x>99 then GOTO 900
.

300 .
If y=0 the GOSUB 1200
.
900 .
.
1200 ..

RETURN
GOTO 300
..
END

1. Classical Programming.
main(){
int x,y,z;
scanf(%d,%d,&x,&y);
z=sum(x,y) + mul (x,y);
printf(z=%d,z);
}

int sum(int a,int b) {
int z;
z=a+b;
return z;
}

int mul(int a,int b) {
int z;
z=a*b;
return z;
}
2. Structured Programming.
Object Orientation is a real world approach to understand and
develop systems.

What is an object ?
An object is any thing, real or abstract, that can have properties
(data) and behavior (methods). It is an instance of a class.

3. Object Oriented Programming
Objective Thinking:
The designer thinks in terms of objects behavior not low-level
details.

Reusability:
Classes are designed so that they can be reused in many
systems (DLLs, OCXs, JARs, ..) - ( new software market).
1. Legacy Components
2. Vendor Product
3. New Software.
Why OOPs?
Interoperability:
Software from many different vendors can work together. (OMG
Standards)

Ever - Growing Complex Classes:
Complex software components become building blocks for more
complex software.

Reliability:
Software built from well-proven classes is likely to have fewer
bugs than software invented from scratch.

Elements of OOP
1. Classes
2. Properties
3. Methods
4. Inheritance
5. Encapsulation
6. Messages
7. Polymorphism
8. Objects
1. Classes
In the real world, you often have many objects of the same
kind.: People, Cars, Animals,

Using object-oriented terminology, your KIA-car object is an
instance of the class of objects known as Car.

Cars have some state (current gear, 4 wheels) and behavior
(change gears, brake) in common.

However, each car's state is independent of and can be different
from other cars.

In object-oriented software, it's also possible to have many
objects of the same kind that share characteristics:
rectangles,
employee records,
video clips
communication channels


A class is a blueprint or prototype that defines the variables
and methods common to all objects of a certain kind.

2. Properties



Name ...
Color ...
Weight
Birth date
etc .


ID Card
A class contains data field descriptions (or properties, fields,
data members, attributes)
Field types and names, that will be associated with either per-
object or per-class state variables at program run time.
Methods implement object behavior.

They provide a means to access objects state.

A method is a sequence of instructions an object must follow
to perform a task.

3. Methods
eat
run
dance run
Car
Mercedes KIA Hyundai
A-Class C-Class E-Class
Accent Sonata
4. Inheritance
In object-oriented terminology:
Hyundai, KIA, and Mercedes are all subclasses of the Car class.
Similarly, the Car class is the superclass of Hyundai, KIA, and
Mercedes .
Inheritance provides a powerful and natural mechanism for
organizing and structuring software programs.
Object-oriented systems take this a step further and allow classes
to be defined in terms of other classes.

A language mechanism for restricting access to some of the
object's components

A language construct that facilitates the bundling of data with
the methods (or other functions) operating on that data.
5. Encapsulation
6. Messages
A single object alone is generally not very useful and usually
appears as a component of a larger program or application that
contains many other objects.
Software objects interact and communicate with each other by
sending messages to each other

Components Of A Message

1. The object to whom the message is addressed (Car)
2. The name of the method to perform (changeGears)
3. Any parameters needed by the method (lower gear)
Driver
Car
7. Polymorphism




RUN!
?
?
?
?
?
Robot run
Bird run
Horse run
8. Objects
Objects are Things
They have state and behavior
An object is a software bundle of variables and related
methods.
Software objects are often used to model real-world objects
you find in everyday life.
A software object maintains its state in variables and
implements its behavior with methods.

Everything that the software object knows (state) and can do
(behavior) is expressed by the variables and methods within
that object.
A Sample Object
A software object that modeled your real-world car would have:
variables that indicated its current state: its speed is 90 mph,
and its current gear is the 4th gear.
The bicycle would also have methods to brake, and change
gears.
Driver
Car

S-ar putea să vă placă și