LECTURE 1 - Introduction
LECTURE 1 - Introduction
Introduction to OOP
Expected Learning Outcomes:
By the end of this lesson, you should be able to:
i. Introduction to Object Oriented Concepts
ii. Benefits of OOP
Software Crisis
Developments in the software industry continue to be mulled with a lot of challenges
Software tools and technologies are developed daily
It has forced software engineers to be keen with the approaches they adopt to stop
The need for changes have created crises within the software industry and need to be addressed
Page 1 of 8
2
Virtual Classes Notes
Procedure-Oriented Programming
In procedure-oriented programming, the problem is viewed as the sequence of things to be
done such as reading, calculating and printing
The primary focus is functions
Examples of languages that use procedural programming include COBOL, FORTRAN, and C
Page 2 of 8
3
Virtual Classes Notes
Object-Oriented Paradigm
Eliminates the problems that were encountered in procedural programming
Object Oriented Paradigm treats data as a critical element and thus does not allow it to flow
freely within the system
It ties data to a function that uses it and protects it from accidental modification from outside
OOP allows decomposition of a problem into a number of entities called objects and then
builds data and function around these objects
Page 3 of 8
4
Virtual Classes Notes
Page 4 of 8
5
Virtual Classes Notes
Classes
Classes are user-defined data type but also has functions in it
A class, therefore is a blueprint for an object
It declares and defines what data variables the object will have and what operations can be
performed on the class’s object
For example mango, apple, and orange are members of fruit class
If fruit has been defined as a class, then the statement Fruit Mango;
will create an object mango belonging to the class fruit
Inheritance
Inheritance is the process by which objects of one class acquired the properties of objects of
another class
Example class ‘robin’ is part of class ‘flying bird’ which is again part of the class ‘bird’
Page 5 of 8
6
Virtual Classes Notes
The logic behind this division is that each derived class shares common characteristics with the
class from which it is derived
In OOP, the concept of inheritance provides the idea of reusability
This means we can have additional features to a class without modifying it
This is possible by deriving a new class from the existing one
Polymorphism
Polymorphism is the 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 the operation
Consider the operation addition. For two numbers the operation will be a sum. For two strings,
it will be concatenation
The process of making an operator exhibit different behaviors in different instances is known as
operator overloading
Page 6 of 8
7
Virtual Classes Notes
Polymorphism plays an important role in allowing objects having different internal structures to
share the same internal interfaces
This means that a general class of operations may be accessed n the same manner even though
specific action associated with each other may differ
It is used extensively in inheritance
Exception Handling
Exception handling is a feature in OOP
Used to handle unresolved conflict
Benefits of OOP
The advantages of OOP include:
Eliminate redundant code by re-using classes
It eliminates the need to re-invent the wheel by having to reuse modules already
developed
Data hiding enables programmers enhance security of their data
Possible to have many instances of an object without interference
Partitioning of projects is easily achieved
Easy upgrade from small to large system
Easy to manage software complexity
Page 7 of 8
8
Virtual Classes Notes
Page 8 of 8