Professional Documents
Culture Documents
1 Introduction
1. one of the most critical aspect of software development
and management in software industry is “change “.
5
6
in multi function program many data item placed
as global so that they may be accessed by all the
functions , each function may have it own local data
7
global data are more vulnerable to change by other
function since it is difficult to identify what data is
used by which function.
some of characteristics(features) of POP
Emphasis on doing things (algorithms)
large programs divided into smaller programs
known as function
Most of function share global data
Function transform data from one to another
Employs top – down approach in program design
8
1.3 Object oriented programming paradigm
the objective of object oriented programming is to
overcome the drawback of procedure oriented by :-
I. treats data as critical element
II. it ties the data more closely to the functions that operate
on it and protect it from accidental modification from
outside function.
III. OOP allow to decompose a problem intro a number of
entities called object and then builds data and
functions(known as methods in C#) around these entities .
9
The combination of data and methods make up an object
Therefore ,
Object = data + methods
10
the data of one object can be accessed only by functions
associated with that object
Functions of one object can access the functions of other
objects .
11
characteristics(features) of object oriented programming
emphasis on data rather than function
Programs divided into what known as objects
Data structure designed such that they characterize the
objects.
Functions that operate on the data of an object are tied
together in the data structure
data is hidden and cannot be accessed by external function
objects may communicate with each other through
methods
new data and function can be easily added
Follows bottom – up approach in program design
12
So, we define object oriented programming as :-
An approach that provide away of modularizing
programs by creating partitioned memory area for
both data and functions that can be used as
templates for creating copies of such modules on
demand.
13
1.4 Basic Concepts of object oriented programming
14
Ex :customer and account are two objects in banking program
then the customer object may send a message to account
object requesting for balance, each object contains data
and code to manipulate the data.
Objects can interact without having to know the details of
each others data or code. instead it is sufficient to know
type of message accepted and type of response returned
by the objects.
Representation of object
15
16
The object contain data and code to manipulate that
code
A CLASS may be thought of as a data type and an object
as a variable of that data type. Once a class defined we can
create any number of objects belonging to that class.
thus , A CLASS is a collection of objects of similar type.
For example mango , apple and orange are members of
class fruit
A CLASS is a user defined data type and behave like built
in type of programming language.
If fruit has been defined as a class, then :
fruit mango; will create an object mango belong to
the class fruit.
17
2. Data abstraction and encapsulation
data encapsulation
means wrapping of data and methods into a single unit
called class.
the data is not accessible to the outside world and only
those methods which are wrapped in the class can access it
These methods provide the interface between the object’s
data and the program.
data hiding means that the insulation of the data from
direct access by the program.
18
data abstraction
refer to the act of representing essential features without
including the background details or explanation.
classes that use the concept of abstraction and are defined
as list of abstract attribute such as size, weight and cost .
And methods that operate on these attributes.
They encapsulate all the essential features of the objects
that are to be created .
encapsulation is of the OOP principles .
19
3. Inheritance
is the process by which objects of one class acquire the
properties of objects of another class.
inheritance support the concept of hierarchical
classification for example the bird Robin is part of the class
flying bird which is again part of the class bird.
Property
inheritance
20
in OOP the concept of inheritance provide the idea of
reusability . i.e. we can add additional features to an
existing class without modifying it . This is done by deriving
a new class from existing one.
the new class will have the combined features of both the
classes .
in C# the derived class known as subclass or child class and
the main class called super class or parent class.
21
22
4. Polymorphism
is another important OOP concept.
Polymorphism means the ability to take more than one
form for example an operation may exhibit different
behavior in different instance.
the behavior depends upon the type of data used in the
operation. For example consider the operation of addition
for two number the operation will generate a sum if the
operands are strings then the operation would produce a
third string by concatenation . For example single function
name can be used to handle different number and different
types of arguments. This is similar to a particular word
having several different meaning depending on the context.
23
24
5. Dynamic binding
Refer to linking of a procedure call to the code to be
executed in response to the call.
dynamic binding means that the code associated with a
given procedure call is not known until the time of the call
at runtime
example the procedure “draw” every object will have this
procedure, however unique to each object and so the draw
procedure will be redefined in each class that defined the
object , at run time the code matching the object under
current reference will be called .
25
6. Message communication
object oriented program consist of a set of objects that
communicate with each other.
the process of programming in an object oriented involve
the basic steps :
creating classes that define objects and their behavior
creating objects from class definition
Establishing communication among objects
objects communicate with one another by sending and
receiving information.
26
A message for an object is a request for execution of a
procedure and therefore will invoke a method
(procedure) in the receiving object that generate the
desired result
27
Message passing involve specifying the name of the object ,
the name of the method (message) and the information to be
sent for example consider the statement
28
1.5 Benefits of OOP
1. we can eliminate redundant code and extend the use of existing
classes.
29
4. It is possible to have multiple objects to coexist without any
interference
30
Questions of chapter one
Q1- justify “object oriented programming overcomes the drawback of
procedural oriented programming ”
2- ties the data more closely to the functions that operate on it and protect
it from modification from outside function.
32
4- Inheritance
is the process of acquiring the properties of object of another class
5- Polymorphism
The ability to take more than one form depend on data type such as
the addition “+”can be used to add 2 number or concatenate two
string .
6- dynamic binding
linking of a procedure call to the code to be executed in response to
the call.
7- Message communication
Is a set of objects that communicate with each other by sending and
receiving message.
33
Q3- what is the features of object oriented programming.
Solution:
emphasis on data rather than function
2.we can build programs from the standard working modules rather
than starting writing the code from scratch( saving time)
35
5. It is easy to partition the work in a project based on objects
36
Written on board
• Q5: define
• - objects
• class
• polymorphism
37
Written on board
• Q6: what we mean by reusability ? Justify
38
Written on board
Q7: compare between object oriented
programming and procedure oriented
programming.
39