Download presentation
Presentation is loading. Please wait.
1
Object Orientated Programming
Abstraction Inheritance Polymorphism encapsulation
2
The 4 pillars of Object Oriented Programming
INHERITANCE ENCAPSULATION POLYMORPHISM ABSTRACTION
3
In a nutshell, inheritance is a process of creating new class from the existing one. The new class may have some additional properties and functionality. INHERITANCE
4
Encapsulation is the process of putting data and the operations (functions) that can be performed on that data into a single container called class. Now, any programmer can use this class without knowing how it is implemented. Due to encapsulation, data is insulated, thus not directly accessible from the outside world. This is known as Data Hiding. Remember, Encapsulation is not data hiding, but, Encapsulation leads to data hiding. ENCAPSULATION
5
Note on encapsulation – a helpful illustration
A tiger can walk, smell, eat, hunt, kill and eat … The tiger can do all of these functions without ever knowing or seeing how it does them.
6
Poly means many and Morphs means forms
Poly means many and Morphs means forms. Polymorphism refers to the ability to take multiple forms and it allows us to invoke derived class methods through a base class reference during run-time.. POLYMORPHISM
7
Abstraction is a process of exposing essential features of an entity by hiding the other irrelevant details. Abstraction mainly reduces complexity and increases efficiency. An entity can have multiple abstractions. ABSTRACTION
8
Note on Abstraction Source:
9
Object Oriented Programming
This makes use of the idea of CLASSES and OBJECTS A Class is created (as a sort of ultimate BLUEPRINT or TEMPLATE) of an object. All Objects are then INSTANCES (or instantiations) of that CLASS.
11
PLATO Plato was born in Athens, Greece in the year 428 BCE and was tutored by Socrates (often credited as the father of Western philosophy). However, it is Plato, not Socrates, who is arguably the best known of the ancient Greek philosophers (if not of all philosophers), due in large to his profound influence on modern philosophy through his legacy of prolific writings; 35 dialogues and 13 letters.
12
Theory of Forms Beautiful?
13
What is Beauty?
14
Can the thing we call “beauty” be personified? What is Beauty?
15
Can the thing we call “beauty” be personified? What is Beauty?
16
The “Form” of True Beauty
A flower is beautiful and a picture can also be said to be beautiful, but neither are beauty itself. Plato argues that the form of true beauty exists independently of the objects that have it, as such we may have a notion of perfect beauty, but can never actually experience it first hand.
17
Beauty is a quality INHERITED from the true form BEAUTY (that exists …
Beauty is a quality INHERITED from the true form BEAUTY (that exists ….somewhere!) In Plato’s parlance, a flower is said to partake of the form of beauty. It’s beautiful, but we never see true beauty. The flower is said to be a particular that inherits its qualities from the forms, one of which is beauty. The form of true beauty is constant and unchanging, whereas a flower may possess beauty for a while, but ultimately looses it when it withers and dies. Being abstract, forms exist independently of the particulars or real world objects that inherit their qualities.
18
Plato’s ideas are tat Every OBJECT, thing, thought or IDEA in this world is merely an “INSTANCE” or a MANIFESTATION of a TRUE AND ABSOLUTE TEMPLATE (or Class) of that object that exists in TRUE REALITY
19
Take Chairs…. A Chair (or a Chair Class) is like a TEMPLATE or an ABSTRACT (idea) of what a CHAIR is. The Chair class tells us WHAT A CHAIR COMPRISES OF, WHAT IT CAN DO, WHAT IT SHOULD LIKE, etc. A Chair Has legs Can be sat on Has a Colour Has a Shape
20
If a Carpenter made a Chair now ….
The Chair INHERITS properties and methods from the original IDEA of a Chair. In programming we could call this a CLASS
21
Take Visual Basic and Buttons
When you create a Button on a form you are: 1. Creating an INSTANCE of the BUTTON CLASS (The button class already exists and you cannot change it) The Button class defines what a Button is – what properties and events and methods it has. Every button you create can be clicked….will have a shape etc.
22
Everything in the toolbox has already been created as a Class.
23
When you make a button – you make an instance of the button class.
24
Pre-defined Properties of the Button
Pre-defined Properties of the Button! (these are INHERITED from the Button Class)
25
C = Procedural Language
What could go wrong here?
26
The main idea of OOP Is: To gather data AND Methods (functions) that act upon that data into ONE entity – called a CLASS. When you have a class it means 1 DATA HIDING 2 CODE RE-USE and 3 PROGRAM MAINTENANCE much easier!
27
Classes can be thought of as “Black Boxes”
Other programmers don’t know what the class contains but can manipulate it using its METHODS
28
Languages in the olden days
Treated data and Programming instructions as separate things
29
Derived Class? A Class that has all the properties and methods (or attributes and operations) of its super class but may also have attributes and operations of its own!
30
The 4 pillars of Object Oriented Programming
INHERITANCE ENCAPSULATION POLYMORPHISM ABSTRACTION
31
Inheritance? A Derived Class INHERITS all the attributes and operations from its super class.
32
Encapsulation? Data Hiding
Data can only be accessed using operations or methods defined for the class Maintains data integrity
33
Polymorphism Data Hiding
Data can only be accessed using operations or methods defined for the class Maintains data integrity
34
What are the advantages of OOP?
35
Disadvantages of OOP?
36
From http://www. richardfarrar
Throughout his metaphysical discussions, Plato refers to forms as abstract representations that are templates or patterns for real world objects or characteristics of objects. By way of example, to explain the concept of a form, Plato discusses the concept of beauty. A flower is beautiful and a picture can also be said to be beautiful, but neither are beauty itself. Plato argues that the form of true beauty exists independently of the objects that have it, as such we may have a notion of perfect beauty, but can never actually experience it first hand. In Plato’s parlance, a flower is said to partake of the form of beauty. It’s beautiful, but we never see true beauty. The flower is said to be a particular that inherits its qualities from the forms, one of which is beauty. The form of true beauty is constant and unchanging, whereas a flower may possess beauty for a while, but ultimately looses it when it withers and dies. Being abstract, forms exist independently of the particulars or real world objects that inherit their qualities. Heavy stuff at the best of times, let alone for over two millennia ago.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.