You are on page 1of 38

1.

1 Introduction
1. one of the most critical aspect of software development
and management in software industry is “change “.

2. number of issues that must be addressed by software


engineer most important among them are
(maintainability , reusability , portability , security , integrity )

3. To build complex software, it is not enough to put together


a sequence of programming statement instead we need to
use techniques that is :-
(easy to understand , easy to implement , easy to modify )
2
4. With the advent of languages such as C language , the
structured programming become very popular 1980
however, as the program grow larger the structured
approach failed to show desired result in term of
bug free , easy to maintain , reusable programs.

5. Object oriented programming is an approach to


program organization and development which
attempt to eliminate drawback of conventional
programming method by incorporating the best of
structured programming features with new
concepts. 3
1.2 A look at procedure oriented language(POP)

 conventional programming using high level language such


as COBOL , FORTRAN and C is known as procedure
oriented programming (POP).

 in procedure oriented programming the problem viewed as


sequence of things to be done such as reading , calculating ,
and printing. Where a numbers of function are written to
accomplish these task.

 POP focus on function rather than data

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

1. Objects and classes


 objects are basic runtime entities in object oriented system . Such as
person , a place , a bank account, a table of data or any item that the
program may handle. Or user defined data type such as vector and lists.

 Object take place in memory and has associated address

 when program executed the objects interact by sending messages to


one another for example :

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.

2. we can build programs from the standard working modules rather


than having to start writing the code from scratch this lead to saving
of time

3. the principle of data hiding helps the programmer to build secure


programs .

29
4. It is possible to have multiple objects to coexist without any
interference

5. It is easy to partition the work in a project based on objects

6. Object oriented systems can be easily upgraded from small to large


system.

7. Message passing technique for communication between objects


make the interface descriptions with external system much simpler

8. Software complexity can be easily managed.

30
Questions of chapter one
Q1- justify “object oriented programming overcomes the drawback of
procedural oriented programming ”

Solution: the object oriented language :-

1- treat data as critical element .

2- ties the data more closely to the functions that operate on it and protect
it from modification from outside function.

3- object oriented allow to decompose a problem into a number of object


and builds data and functions around the objects.

4-new data and function can be easily added


31
Q2- state the concepts of object oriented programming and explain
each one briefly
Solution:
1- class and object
Class: is a template/blue print describes the behaviours
And methods of an object.
Object:  is an instance of a class have behaviour and methods.
2- data encapsulation
wrapping of data and methods into a single unit called class
3- data abstraction
representing essential features without including the background details

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

 Programs divided into what known as objects

 Functions that operate on the data of an object are tied together

 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


34
Q4- what is the benefits of object oriented programming
Solution
1.we can eliminate redundant code and extend the use of existing
classes.

2.we can build programs from the standard working modules rather
than starting writing the code from scratch( saving time)

3.the principle of data hiding helps the programmer to build secure


programs .

4. It is possible to have multiple objects to coexist without any


interference

35
5. It is easy to partition the work in a project based on objects

6. Object oriented systems can be easily upgraded from small to


large system.

7. Message passing technique make the interface descriptions with


external system much simpler

8. Software complexity can be easily managed

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

You might also like