0% found this document useful (0 votes)
113 views20 pages

Object-Oriented Programming - PPT - Benjamin Babić

The document discusses the key concepts of object-oriented programming including encapsulation, abstraction, inheritance, and polymorphism. Encapsulation bundles data and methods into a single unit and restricts access via getters and setters. Abstraction hides unnecessary details and shows essential attributes. Inheritance eliminates redundant code through subclassing and code reuse. Polymorphism allows for multiple forms through interfaces that can be implemented differently. These pillars provide benefits like reduced complexity, isolation of changes, code reuse, and extensibility.

Uploaded by

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

Object-Oriented Programming - PPT - Benjamin Babić

The document discusses the key concepts of object-oriented programming including encapsulation, abstraction, inheritance, and polymorphism. Encapsulation bundles data and methods into a single unit and restricts access via getters and setters. Abstraction hides unnecessary details and shows essential attributes. Inheritance eliminates redundant code through subclassing and code reuse. Polymorphism allows for multiple forms through interfaces that can be implemented differently. These pillars provide benefits like reduced complexity, isolation of changes, code reuse, and extensibility.

Uploaded by

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

OBJECT-ORIENTED PROGRAMMING

Benjamin Babić

Zagreb University of Applied Sciences - 28.3.2021.


INTRODUCTION
PROCEDURAL PROGRAMMING

 Before object-oriented programming we had


„procedural programming”

 Divides programming into a set of functions and


variables that operate on the data

 Plain simple, straightforward

 Problems => „Spaghetti Code”


 Interdependence

2
O B J E C T- O R I E N T E D
PROGARMMING
P R O G R A M M I N G PA R A D I G M

 Combining group of related variables and functions into a


unit => object Real World => Code
 Variables = Properties of an object
 Methods = Functions of an object
 Example: Calculator

PROPERTIES METHODS

Dimensions Addition
Model Division
Colour Exponentiation
Weight Square Root
Battery Type Trigonometric functions
3
PILLARS OF
OBJECT-
ORIENTED
PROGARMMING
CORE CONCEPT

4
ENCAPSULATIO
N

5
E N C A P S U L AT I O N

 DEFINITION: bundling of data, along with the methods that operate on that data, into a single unit.

 Mechanism of restricting the direct access to some components of an object

Information hiding

 Getter: retrieve the value of a specific variable within a class.


 Setter: set or update the value of a specific variable within a class.
 Access modifiers: define the visibility and accessibility of classes, their data and methods
 Implementation => protecting sensitive data

6
The best functions are those with no
parameters !

ROBERT C. MARTIN
ABSTRACTION

9
A B ST R AC T I O N

 DEFINITION: Showing essential attributes to the user


and hiding unnecessary information

 Example: Computer Monitor / DVD

 Only a few buttons

 How it works? ==> Hidden Complexity

 Simple interface, reduce the impact of change

10
11
INHERITANCE

12
I N H E R I TA N C E PARENT CLASS

 DEFINITION: Mechanism that helps to eliminate


redundant code while increasing code reusability

 Subclass = Extended Class = Child Class CHILD CLASS CHILD CLASS

 Super Class = Base Class = Parent Class

 Example: Car

PROPERTIES METHODS

Color Start
Fuel Accelerate
Model Brake
Transmision Type Gear Shift
Number of doors/seats Directional signals

13
14
POLYMORPHISM

15
P O LY M O R P H I S M MOVE CLASS

 Poly = Many, Morph = Form => existing in many forms


SNAIL KANGAROO
 DEFINITION: The ability to create a property, a function or an
object that has more than one realization.
DOG FISH
 Concept: Different classes can be used with the same interface

 Two types of Polymorphism:

- Runtime

- Compile Time

16
17
BENEFITS
E N C A P S U L AT I O N
 Reduce complexity, limiting vulnerabilities, data protection

ABSTRACTION
 Show essential attributes, isolate impact of changes

I N H E R I TA N C E
 Eliminate redundant code, code reusability

P O LY M O R P H I S M
 Enforcing simplicity, saving time, extandable codes, easily
maintained applications

18
QUESTIONS?

Benjamin Babić [email protected]


L I T E R AT U R E

 https://www.sumologic.com/glossary/encapsulation/
 https://stackify.com/oop-concept-polymorphism/
 https://en.wikipedia.org/wiki/Object-oriented_programming#Encapsulation
 https://en.wikipedia.org/wiki/Inheritance_(object-oriented_programming)
 https://www.youtube.com/watch?v=1ONhXmQuWP8
 https://en.wikipedia.org/wiki/Polymorphism_(computer_science)
 https://en.wikipedia.org/wiki/Encapsulation_(computer_programming)
 https://en.wikipedia.org/wiki/Abstraction_(computer_science)
 https://docs.oracle.com/javase/tutorial/java/IandI/subclasses.html
 https://www.nerd.vision/post/polymorphism-encapsulation-data-abstraction-and-inheritance-in-object-ori
ented-programming

You might also like