Chaptero 1
Chaptero 1
Compiled by:
Tefera.S (PhD. Candidate in Information Science @ JIT).
27/04/2025 5
• Procedure-oriented programming consists of writing a list of
instructions (actions) for the computer to follow and organising these
instructions into groups known as functions.
• A serious drawback of the procedural approach is that it does not
model real-world problems very well.
• Because functions are action-oriented and do not correspond to
the elements of the problem.
• Some characteristics exhibited by procedure-oriented programming
are:
• Emphasis is on doing things (algorithms).
• Large programs are separated into smaller programs known as
Functions.
• Most of the functions help to share global data.
• Data moves openly around the system from function to function.
• Functions enhance to transform data from one to another
programming bodies.
• Employs a top-down approach in program design.
27/04/2025 6
B) Structured Programming Paradigms
• (SPP):-is a special type of procedural programming:-
27/04/2025 7
C) Object-Oriented Programming Paradigms (OOPP)
27/04/2025 9
Some of the striking features of OOP are:
• Data structures are designed such that they describe the objects.
27/04/2025 11
Objects
27/04/2025 13
Classes
• Objects are variables of the type class.
• Once a class has been defined, we can create any
number of objects belonging to that class.
• Each object is associated with the data of the type class
with which they are created.
• A class is thus a collection of objects of similar type.
• For example, mango, apple and orange are members of the
class fruit.
• Classes are user-defined data types and behave like the
built-in types of a programming language.
• If fruit has been defined as a class, then the statement
• fruit mango; Orange, Banana…..
• will create as an objects belonging to the class fruit.
27/04/2025 14
Data Abstraction and Encapsulation
• The data is not accessible to the outside world, and only those
functions, which are wrapped in the class can access it.
• Functions offer the interface B/n the object’s data & the
program.
attributes such as size, weight, cost, and functions to operate on these attributes.
• They encapsulate all the essential properties of the objects that are to be created.
• The attributes are sometimes called data members, b/c they hold evidence.
• The functions that operate on these data are sometimes called methods /member
functions.
• Since the classes use the concept of data abstraction, they are known as Abstract
27/04/2025 16
Inheritance
• For example, the bird ‘robin’ is a part of the class ‘flying bird’ which
is again a part of the class ‘bird’.
• The belief behind this sort of division is that each derived class
shares common characteristics with the class from which it is derived.
27/04/2025 17
Cont…
27/04/2025 18
Cont…
• In OOP, the concept of inheritance provides the idea of reusability.
• This means we can add extra features to an existing class without modifying it.
• This is possible by deriving a new class from the existing one.
• The new class will have the combined features of both classes.
Polymorphism
• It is a Greek term, that means the ability to take more than one form.
• An operation may exhibit unlike behaviours in unlike instances.
• The behaviour depends upon the types of data used in the operation.
• For example, consider the operation of addition (+).
• For two numbers, the operation will generate a sum (2+3=5).
• If the operands are strings, then the operation would produce a third string by concatenation
(string 1 =“Hello,”, string2 = “World!”; result = string1 + string2 and print (result) then the
output = Hello, World!).
• The process of making an operator exhibit diverse behaviours in diverse instances
is known as operator overloading.
27/04/2025 19
Cont…
• Using a single function name to perform diverse types of
tasks is known as function overloading.
• 27/04/2025
Polymorphism is extensively used in implementing 20
Cont…
27/04/2025 21
Dynamic Binding
27/04/2025 23
Message Passing
27/04/2025 24
• Objects communicate with one another by sending and
receiving info much the same way as people pass
messages to one another.
• A message for an object is a request for execution of a
procedure and therefore will invoke a function (procedure)
in the receiving object that generates the desired result.
• Message passing involves specifying the name of the
object, the name of the function (message) and the
information to be sent.
27/04/2025 25
Cont...
• Objects have a life cycle.
• They can be created and destroyed.
• Communication with an object is feasible as long as it is alive.
Benefits of OOP
• OOP offers many benefits to both the program designer and the
user.
• Object-orientation contributes to the solution of many problems
associated with the development and quality of software products.
• Through inheritance, we can eliminate redundant code and extend
the use of the existing class
• We can build programs from the standard working modules that
communicate with one another, rather than having to start writing
the code from scratch.
• This leads to saving development time and higher productivity
27/04/2025 26
Cont...
• The principle of data hiding helps the programmer build
secure programs that cannot be invaded by code in
other parts of the program.
• It is possible to have multiple instances of an object to
co-exist without any interference.
• It is easy to partition the work in a project based on
objects
• Software complexity can be easily managed.
27/04/2025 27
Some of the Applications of OOP:-
• Real-time systems
• Object-oriented databases
27/04/2025 29