0% found this document useful (0 votes)
14 views

Introduction To Object Oriented Programming Object Oriented Programming

This document provides an introduction to object oriented programming (OOP). It explains that OOP involves modeling programs around real-world objects, with data and functions grouped together as objects that communicate through message passing. It contrasts this with procedural programming, which focuses on functions and algorithms. The document then outlines key concepts in OOP like classes, abstraction, encapsulation, inheritance, polymorphism, and message passing.

Uploaded by

john agai
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Introduction To Object Oriented Programming Object Oriented Programming

This document provides an introduction to object oriented programming (OOP). It explains that OOP involves modeling programs around real-world objects, with data and functions grouped together as objects that communicate through message passing. It contrasts this with procedural programming, which focuses on functions and algorithms. The document then outlines key concepts in OOP like classes, abstraction, encapsulation, inheritance, polymorphism, and message passing.

Uploaded by

john agai
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

INTRODUCTION TO OBJECT ORIENTED PROGRAMMING

Object oriented programming


Creating a computer program as a collection of modules which are abstractions of real world
objects.
OOP was invented to remove flaws encountered in the procedural approach, oop allows
decomposition of a problem into a number of entities called objects and then builds data and
functions around these objects.
Features of OOP
 Emphasis is on data rather than procedure.
 Programs are divided into objects.
 Data structures are designed such that they characterize the objects.
 Data is hidden and cannot be accessed by external functions.
 Objects communicate with each other through message passing
 Follow bottom-up approach in program design
Procedure oriented programming
Conventional programming, using high level languages such as COBOL, FORTRAN and C, is
commonly known as procedure-oriented programming (POP), in this approach the problem is
viewed as a sequence of things to be done such as reading, calculating or printing. A number of
functions are written to accomplish these tasks.
POP basically consists of writing a list of instructions for the computer to follow and organizing
these instructions into groups known as functions. Normally a flowchart is used to organize these
instructions and represent the flow of control from one action to another.
Features of a POP
 Use of algorithms (flowchart).
 Large programs are divided into smaller programs known as functions.
 Most of the functions share global data.
 Data move openly around the system from function to function.
 Employs a top-down approach in program design.
Basic concepts of OOP
Concepts mainly used in OOP include
 Objects
 Classes
 Abstraction
 Encapsulation
 Inheritance
 Polymorphism
 Message passing

i) Objects
These are basic run-time entities in an object oriented system they may represent a person, place,
bank account a table of data or any item that the program has to handle. Objects also represent
user defined data such as vectors, time and lists.
The concept of object is used simplify the representation of complex real world structures as
software structures in the computer.
Objects enable abstraction of the real world and structural representation in the computer.
ii) Classes
A class is a collection of objects of similar type classes can be concretely defined example
apples, banana, and mangos are members of a class fruit. Classes are user-defined data types and
behave like the built-in types of a programming language.
Types of classes
 Abstract class
 Concrete class
 Active Class

iii) Abstraction
A concept important for simplification of representation of complex structures
Representation of complex structure by simpler structure that hide the complex details
In computer science abstraction has enabled the development of various levels of programming
languages that enable simplify the definition of the program and data structures that would be
difficult to do with the natural language of the computer.
This has simplified the development of the large programs that provide real world solutions –
programs that would be difficult to implement with the machine language
iv) Encapsulation
The containment or packaging of data and the functions that use the data in a program module.
Encapsulation protects the data from modification by functions external to the object.
This is implemented by definition of abstract structure referred to as class that represents the type
of object.
Facilitates information hiding which is an important characteristic that enables create reliable
programs

v) Inheritance
Is the process by which objects of one class acquire the properties of objects of
another class.
A concept used in object oriented programming to describe the relationship between
types of objects where one object is a sub type of another.
Inheritance is one of the approach to employing reuse in programming.
Reuse by inheritance enables to take an existing type of object, clone it and then make
additions and modifications to the clone.
Types of inheritance
– Single inheritance - A sub type of an object inherits from only one super type.
– Multiple inheritance - A sub type of an object inherits from two or more super
types.
– Repeated inheritance - A special multiple inheritance where the super types of a
subtype inherit from another super type.
– Selective inheritance - Limited inheritance of a subtype from its super type.
Restricting access to some details in the super type

vi) Polymorphism
Polymorphism is a Greek term which means ability to take more than one form. An operation
may exhibit different behaviors in different instances. The behavior depends upon the types of
data used in operation.
Types of polymorphism
Overloading- This is changing the implementation of a method inherited from a parent class. The
name, arguments and the return type remain the same but the action differs
Overriding- This means using the same name for different methods in a class.
vii) Message passing
This refers to the communication between objects. Objects communicate with one another by
sending and receiving information.

You might also like