Sie sind auf Seite 1von 17

Object Oriented Programming

Chapter 1: Introduction to OOP


I am here because I love to give knowledge.
Outlines
◉ What is Object-Oriented Programming ?
◉ Procedural vs. Object-Oriented Programming
◉ OO ProgrammingConcepts
◉ Concept of Objects and classes
◉ UML Class Diagram
◉ Visibility Modifiers and Accessor Methods
◉ Full Example
Lecture 1
Let’s start with the first set of concepts
Our Life is a set of
Objects
What is OOP?

o To have a fine definition of OOP, Please note what you


are showing in your class room now?

Chairs #of legs


Tables Type of material
Teacher Color
PCs .
. .
. .
What is OOP?

o Object-oriented programming (OOP) involves programming using


objects.
o An object represents an entity in the real world that can be
distinctly identified.
o For example, a student, a desk, a circle, a button, and even a loan
can all be viewed as objects.
o An object has a unique identity, state, and behaviors.
Procedural vs. Object-Oriented Programming

o The unit in procedural programming o The unit in object-oriented


is function. programming is class.
o Procedural programming o Object-oriented programming
concentrates on creating functions. starts from isolating the classes,
o Procedural programming separates and then look for the methods
the data of the program from the inside them.
operations that manipulate the o Object-oriented programming
data. focus on both of them.
Concepts of Object-Oriented Programming
Abstraction

o Abstraction is simplifying complex reality by modeling classes


appropriate to the problem.
o Abstraction is mechanism to show only relevant data to the user.
o i.e: The client cares about what functionality a car offers, not
about how that functionality is implemented.
Encapsulation

o Encapsulation allows the programmer to group data and the


methods that operate on them together in one place, and to hide
details from the user.
withDraw any value

AccountValue
Change Address
Name Address
Benefits of encapsulation

o Encapsulation protects the integrity of an object's data.


o Protects an object from unwanted access by clients.
 A bank app forbids a client to change an Account's balance.

o Allows you to change the class implementation.


o Allows you to constrain objects' state
Abstraction Vs encapsulation
Inheritance

o Inheritance: The ability of a new class to be created from an


existing class by extending it.
Student

Colleague School

BCs Diploma Primary Secondary


Polymorphism

o Polymorphism enables us to "program in the general" rather than


"program in the specific.
Practices
Group 1 Group 2 Group 3
Compare between Detect 5 objects from Diffrenciate between
the main concepts of our classroom abstraction and
OOP. encapsulation.

Group 4 Group 5 Group 6


Diffrenciate between Give us 3 examples for Summerize the first
procedural and Object- inheritance from your lecture using 1 complext
Oriented Programming life. chart.
THANKS!
Any questions?

Das könnte Ihnen auch gefallen