Spotle.ai Study Material
Spotle.ai/Learn
Introduction To
OOPS
Key Principles
And
Advantages
Spotle.ai Study Material
Spotle.ai/Learn
Mousum Dutta
Chief Data Scientist, Spotle.ai
IIT Kharagpur
Instructors
Sk Mamtajuddin
Head of Technology,
Spotle.ai
2
Spotle.ai Study Material
Spotle.ai/Learn
OOPS is based on
the programming
paradigm of
objects containing
data and methods.
The OOPS Paradigm
Image Source: Wikipedia
Spotle.ai Study Material
Spotle.ai/Learn
The OOPS Paradigm
//Example Of An Object
BankAccount MyAccount =new
BankAccount();
//MyAccount is an instace of Class
BankAccount
MyAccount. Balance = 0;
//Balance is a property of
MyAccount object
MyAccount.getMoneyFromDad();
//getMoneyFromDad() is a method
of the MyAccount object
An Example
Spotle.ai Study Material
Spotle.ai/Learn
The OOPS Principles
Encapsulation Abstraction
Polymorphism Inheritance
OOPS
Principles
Spotle.ai Study Material
Spotle.ai/Learn
What Is Encapsulation?
Encapsulation describes
the concept of bundling
together data and
methods in one unit. It
protects the data within an
object allowing access
only through designated
methods.
6
//Data
Float balance;
//Methods
getBalance()
The MyAccount Object
Spotle.ai Study Material
Spotle.ai/Learn
What Is Abstraction?
Abstraction describes the
concept of hiding
implementation details while
only exposing functionalities
to users.
Example: The account object
gives you your money when
you invoke the withdraw()
method. You do not know and
do not care how it is
implemented.
7
Float pocket_money =
MyAccount.withdraw(500);
Spotle.ai Study Material
Spotle.ai/Learn
What Is Polymorphism?
8
Polymorphism is the concept of one entity providing multiple
implementations or behaviours. (Something like an Avatar)
For example the addition method can add two integers, floats or
concat two strings based on what parameters you are applying
addition on.
Image Source:
Marvel/Planet Photos
Spotle.ai Study Material
Spotle.ai/Learn
What Is Inheritance?
Inheritance is a powerful
construct that lets a child
class (also known as a sub-
class) extends or inherits
from a parent or base class
(also known as a super-
class). The child class
inherits the parent’s
methods and attributes and
then adds its own, enabling
reusability.
Example: In banking, a
priority account extends a
savings account.
9
Spotle.ai Study Material
Spotle.ai/Learn
The OOPS Advantage
10
Better Planning - Helps model real world problems through the object
constructs enabling better planning and modularization of software
projects.
Higher Maintainability - Functionality is encapsulated in separate units –
classes/ methods helping one part of the program to be changed without
affecting others.
More Reusability – Inheritance which lets child classes extend the
functionalities of parent class ensures OOPS delivers high reusability.
Less Complexity– Abstraction and polymorphism reducesthe amount of
information a developer needs to know while working in a large OOPS
system.

Introduction To OOPS - Principles And Advantages

  • 1.
    Spotle.ai Study Material Spotle.ai/Learn IntroductionTo OOPS Key Principles And Advantages
  • 2.
    Spotle.ai Study Material Spotle.ai/Learn MousumDutta Chief Data Scientist, Spotle.ai IIT Kharagpur Instructors Sk Mamtajuddin Head of Technology, Spotle.ai 2
  • 3.
    Spotle.ai Study Material Spotle.ai/Learn OOPSis based on the programming paradigm of objects containing data and methods. The OOPS Paradigm Image Source: Wikipedia
  • 4.
    Spotle.ai Study Material Spotle.ai/Learn TheOOPS Paradigm //Example Of An Object BankAccount MyAccount =new BankAccount(); //MyAccount is an instace of Class BankAccount MyAccount. Balance = 0; //Balance is a property of MyAccount object MyAccount.getMoneyFromDad(); //getMoneyFromDad() is a method of the MyAccount object An Example
  • 5.
    Spotle.ai Study Material Spotle.ai/Learn TheOOPS Principles Encapsulation Abstraction Polymorphism Inheritance OOPS Principles
  • 6.
    Spotle.ai Study Material Spotle.ai/Learn WhatIs Encapsulation? Encapsulation describes the concept of bundling together data and methods in one unit. It protects the data within an object allowing access only through designated methods. 6 //Data Float balance; //Methods getBalance() The MyAccount Object
  • 7.
    Spotle.ai Study Material Spotle.ai/Learn WhatIs Abstraction? Abstraction describes the concept of hiding implementation details while only exposing functionalities to users. Example: The account object gives you your money when you invoke the withdraw() method. You do not know and do not care how it is implemented. 7 Float pocket_money = MyAccount.withdraw(500);
  • 8.
    Spotle.ai Study Material Spotle.ai/Learn WhatIs Polymorphism? 8 Polymorphism is the concept of one entity providing multiple implementations or behaviours. (Something like an Avatar) For example the addition method can add two integers, floats or concat two strings based on what parameters you are applying addition on. Image Source: Marvel/Planet Photos
  • 9.
    Spotle.ai Study Material Spotle.ai/Learn WhatIs Inheritance? Inheritance is a powerful construct that lets a child class (also known as a sub- class) extends or inherits from a parent or base class (also known as a super- class). The child class inherits the parent’s methods and attributes and then adds its own, enabling reusability. Example: In banking, a priority account extends a savings account. 9
  • 10.
    Spotle.ai Study Material Spotle.ai/Learn TheOOPS Advantage 10 Better Planning - Helps model real world problems through the object constructs enabling better planning and modularization of software projects. Higher Maintainability - Functionality is encapsulated in separate units – classes/ methods helping one part of the program to be changed without affecting others. More Reusability – Inheritance which lets child classes extend the functionalities of parent class ensures OOPS delivers high reusability. Less Complexity– Abstraction and polymorphism reducesthe amount of information a developer needs to know while working in a large OOPS system.