0% found this document useful (0 votes)
8 views11 pages

Lec 7

The document outlines the fundamental principles of Object Oriented Programming (OOP), which include encapsulation, inheritance, abstraction, and polymorphism. It explains how abstraction helps in data hiding, encapsulation wraps data and functions together, inheritance allows classes to share properties, and polymorphism enables functions to take multiple forms. Additionally, it discusses the importance of data types and the concept of data hiding in maintaining the integrity of object data.

Uploaded by

suhaib2a55
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views11 pages

Lec 7

The document outlines the fundamental principles of Object Oriented Programming (OOP), which include encapsulation, inheritance, abstraction, and polymorphism. It explains how abstraction helps in data hiding, encapsulation wraps data and functions together, inheritance allows classes to share properties, and polymorphism enables functions to take multiple forms. Additionally, it discusses the importance of data types and the concept of data hiding in maintaining the integrity of object data.

Uploaded by

suhaib2a55
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Object Oriented Programming

Dr. Magdy Zeid

1
Object Oriented Programming
Principles of Object Oriented Programming
• The OOP programming is based on the four major fundamental

principles. The OOP principles includes: ‫اربعه مبادئ اساسية‬

1. Encapsulation

2. Inheritance

3. Abstraction

4. Polymorphism

4
Principles of Object Oriented Programming

5
Basic Object-Oriented Programming

 Abstraction- Abstraction helps in the data hiding process. It helps

in displaying the essential features without showing the details or


the functionality to the user. It avoids unnecessary information or
irrelevant details and shows only that specific part which the user
wants to see.

 Encapsulation- The wrapping up of data and functions together in

a single unit is known as encapsulation. It can be achieved by


making the data members' scope private and the member function’s
scope public to access these data members. Encapsulation makes
the data non-accessible to the outside world.
Basic Object-Oriented Programming
 Inheritance- Inheritance is the process in which two classes have an is-a

relationship among each other and objects of one class acquire properties
and features of the other class. The class which inherits the features is
known as the child class, and the class whose features it inherited is called
the parent class. For example, Class Vehicle is the parent class, and Class
Bus, Car, and Bike are child classes.

 Polymorphism- It means many forms. It is the ability to take more than

one form. It is a feature that provides a function or an operator with more


than one definition. It can be implemented using function overloading,
operator overload, function overriding, virtual function.
Abstraction and Data Types
Abstraction: a definition that captures general characteristics without
details

Ex: An abstract triangle is a 3-sided polygon. A specific triangle may


be scalene )‫ (مختلف األضالع‬, isosceles)‫ (متساوى الساقين‬, or equilateral ‫(متساوى‬
)‫األضالع‬

Ex: An automobile provides an illustration of abstraction. Most people


understand what an automobile is, and many people know how to
drive one. Yet few people understand exactly how an automobile
works or what all its parts are. This is a feature of abstraction.

Data Type: defines the kind of values that can be stored and the
operations that can be performed on the values

7-8
Abstraction in Software Development

Abstraction allows a programmer to design a solution to a problem and to use

data items without concern for how the data items are implemented

Are programmer-created data types that specify

the legal values that can be stored

the operations that can be done on the values

The user of an abstract data type (ADT) does not need to know any

implementation details (e.g., how the data is stored or how the operations

on it are carried out)

7-9
More Object Terms

data hiding: restricting access to certain members of an

object

public interface: members of an object that are available

outside of the object. This allows the object to provide

access to some data and functions without sharing its

internal details and design, and provides some protection

from data corruption


10
More Object-Oriented Programming Terminology
data hiding: restricting data access to certain members of an object. The intent
is to allow only member functions to directly access and modify the object’s data.

When a programmer changes the format or internal structure of an objects


internal data, only the object’s member functions are also modified so they will
still properly operate on it.

These changes, however are hidden from code outside the object. The code
outside the object does not need to know about the changes made to the object’s
data.

The code outside the object can call and use the member functions exactly the
same way as it did before.

encapsulation: the bundling of an object’s data and procedures into a single


entity
7-11

You might also like