SlideShare a Scribd company logo
Object-Oriented Programming
Concepts and Principles
New Wave Analytica
We Find Solutions in Data
Outline
▪ Abstraction
▪ Structured Programming
▪ Procedural vs. Object-Oriented Programming
▪ Goals of Object-Oriented Programming
▪ Principles of Object-Oriented Programming
New Wave Analytica
Abstraction
▪ One of the prime concepts used to simplify programming problems
▪ Mechanism and practice to reduce and factor out details so that one can focus on
a few concepts at a time.
▪ Through the process of abstraction, a programmer hides all but the relevant data
about an object in order to reduce complexity and increase efficiency.
▪ Abstraction is one of the key concepts of object-oriented programming (OOP)
languages.
▪ Its main goal is to handle complexity by hiding unnecessary details from the user.
▪ That enables the user to implement more complex logic on top of the provided
abstraction without understanding or even thinking about all the hidden complexity.
New Wave Analytica
Abstraction
Structured Programming
▪ Further refinement of procedural
programming
▪ Formal methods of planning data flow
and functional decomposition
▪ go to is banned
Structured Programming
▪ A programming paradigm aimed at improving the clarity, quality, and
development time of a computer program by making extensive use of the
structured control flow constructs
▪ Selection (if/then/else)
▪ Repetition (while and for)
▪ Block structures
▪ Subroutines
▪ A programming paradigm in contrast to using simple tests and jumps such
as the go to statement.
New Wave Analytica
Procedural Programming
▪ A programming model which is derived from structured programming, based
upon the concept of calling procedure.
▪ Procedures, also known as routines, subroutines or functions, simply consist of
a series of computational steps to be carried out.
▪ During a program’s execution, any given procedure might be called at any point,
including other procedures or itself.
▪ Languages
▪ Basic
▪ Pascal
▪ C
New Wave Analytica
Procedural Programming
▪ Routines are grouped into functions
▪ A function can call another function
▪ You don’t have to understand each line, lust what each function did
▪ You could hide data to be accessible to only within a function (encapsulation)
New Wave Analytica
Object-Oriented Programming (OOP)
▪ Takes encapsulation even further by localizing data and associated operations
into a mini-program called an object.
▪ An object-oriented program is an ecosystem of objects that interact with each
other.
▪ “Think of an object-oriented system as a bunch of intelligent animals as objects
inside your machine, talking to each other by sending messages to one
another.” – Alllan Holub
New Wave Analytica
Object-Oriented Programming (OOP)
▪ A programming model which is based upon the concept of objects.
▪ Objects contain data in the form of attributes and code in the form of methods.
▪ In OOP, computer programs are designed using the concept of objects that interact with
real world.
▪ OOP languages are various but the most popular ones are class-based, meaning that
objects are instances of classes, which also determine their types.
▪ OOP takes abstraction farthest by allowing you to group related data and operations into
different types of objects.
▪ You create your own data types, which are types of objects. Each of these data types are
called objects.
New Wave Analytica
Object-Oriented Programming (OOP)
▪ Creating you own classes allows you to design a program so that it is
intuitive to remember how it is organized
▪Example
▪ Creating classes that represent real world entities.
▪ Creating classes to have specific responsibilities so that when you need to update a piece of code,
you know exactly where to look for it
▪ Languages
▪ Java, C++, C#, Python, PHP, JavaScript
▪ Ruby, Perl, Objective-C, Dart, Swift, Scala
New Wave Analytica
Goals of Object-Oriented Programming
▪ Comprehensibility
▪ Make it easier for humans to understand you code
▪ Maintainability
▪ Make code easy to modify
▪ Reusability
▪ Old code should be building blocks for new code
▪ Plugability
▪ You can create interchangeable component that can substitute for one another
just like machine parts.
New Wave Analytica
Class and Objects
▪ A class in Java is a blueprint for objects to follow a specific schema defined in the class.
▪ A class defines the behavior for objects of its type. It represents a collection of properties
(data and functions) for all its objects.
▪ It supports a template for creating objects which bind code and data.
▪ A class acts as a means to define methods and data.
▪It helps in maintaining access specifications for member variables using access specifiers.
New Wave Analytica
Class and Objects
▪ An object is the most fundamental entity in Java
▪ Objects represent real-life entities because each of them could have specific behavior,
identity, and data (attributes).
▪ In Java, the object is an offspring of its class.
▪ The class has properties to reflect the object state and methods to represent the behavior.
▪ The methods also show an object’s response to other objects. Identity is a unique name for
the object assigned by the user, much like variables.
New Wave Analytica
What is a Class and an Instance of a Class?
▪ Class
▪ Definition of an object
▪ Example:
▪ Your car is a 2018 BMW 3-series
▪ Instance
▪ The created object of a class
▪ Example :
▪ There are many other 2018 BMW 3-series out there but there is only one instance of your car.
New Wave Analytica
What is an object?
▪ Has attributes
▪ a property or components
▪ Has methods
▪ behaviours or routines
New Wave Analytica
Example of an Object - Car
▪ Attributes
▪ steering wheel
▪ engine
▪ color
▪ radio
▪ airconditoiner
▪ Methods
▪ go forward
▪ go backward
▪ cool the interior
▪ play music
New Wave Analytica
What is an interface?
▪ An object has an interface
▪ The outward appearance of an object. How other objects see the object
▪ The attributes and methods that the object exposes.
▪ Normally, an object will only expose some of its attributes and methods.
▪ Some attributes and methods are used by the object itself. Therefore, no other object
should have access to those
▪ Some attribute and methods may be made accessible only to certain other objects.
▪ Some attributes and methods may be accessible by any other object
New Wave Analytica
What is an interface?
▪ Normally, only methods are exposed. Objects usually hide their data to
protect then from being changed by other objects without their control
▪ Constants are an exception. These don’t change anyway
New Wave Analytica
Three Core Principles of OOP
▪ Encapsulation
▪ Inheritance
▪ Polymorphism
New Wave Analytica
Encapsulation
▪ It is a mechanism of wrapping the data (variables) and code acting on the
data (methods) together as a single unit.
▪ In encapsulation, the variables of a class will be hidden from other classes,
and can be accessed only through the methods of their current class.
▪ Grouping of data and operations into objects.
▪ Related data and operations should not be separated. They should be found
in a single object.
▪ It is also known as data hiding
New Wave Analytica
Encapsulation
▪To achieve encapsulation in Java
▪ Declare the variables of a class as private.
▪ Provide public setter and getter methods to modify and view the variables values.
▪ Benefits of Encapsulation
▪ The fields of a class can be made read-only or write-only
▪ A class can have total control over what is stored in its fields
▪ Simpler interfaces
▪ Only a few methods are exposed to other objects. Since interactions between objects are simple, system us easier for the
programmer to comprehend.
▪ Data protected from corruption
▪ Easier to modify code or find bugs
▪ Simpler interactions
New Wave Analytica
Examples of Encapsulation
▪ You shouldn’t have to ask someone with radar gun to measure the speed of
your car. Your car should have its own speedometer.
▪ Purchase Order Object
▪ Data for purchase orders should not be lumped in the same objects as data for invoices and receipts
▪ The methods for retrieving data from a purchase order should not be found in a separate class from
the data.
▪ DB Connection Object
▪ The DB Connection object should not need to look up the URL from the database from another
object every time its does an operation.
New Wave Analytica
Examples of Encapsulation
▪ Information Hiding
▪ AN object should expose only what is necessary, and only at the appropriate level.
▪ Think of CIA … “need-to-know”
New Wave Analytica
Examples of Encapsulation
▪ Car
▪ Driver : Only steering wheel, pedals, and stick shift are exposed. Driver should not access engire or
gears or axle to drive the car
▪ Mechanic
▪ Access to engine, gears, etc., but not internals of each part
▪Manufacturer
▪ Access to internals of each part
New Wave Analytica
Examples of Encapsulation
▪ Purchase Order Object
▪ Any object can get into from the object, but only certain objects should have authority to set
information.
▪ Only certain objects should be allowed to create PO object
▪ DB Connection Object
▪ Only the Driver Manager object can create a connection
▪ Users cannot set whether a connection is read-only or not.
New Wave Analytica
Inheritance
▪ It is a way to create a new class by deriving from another class.
▪ It is the mechanism in java by which one class is allowed to inherit the
features(fields and methods) of another class.
▪ Interface Inheritance
▪ The new class acquires the interface of the old class
▪ Implementation Inheritance
▪ The new class often also acquires the implementation of the old class
▪ The new class can change the implementation of the older class or ass its methods and
attributes.
New Wave Analytica
Inheritance
▪ Inheritance is a way to allow objects to share code, preventing code-
duplication
▪ Code supplication is the number sin in OOP
▪ Implementation inheritance is dangerous
▪ The Fragile Base Class Problem
▪ A subclass must inherit all inheritable members of the superclass
▪ No option to disinherit a member
▪ If the subclass inherits members that it doesn’t need, those members might be called by other objects in
a way that the creator of the subclass did not intend (remember you’re working in a tem) causing
undesirable behavior
Polymorphism
▪ When a single data type exhibits different behaviours during execution.
▪ Greek : Poly means “many”, morph means “form”
▪ Polymorphism means “existing in many forms”
▪ It is the other side of the same coin as inheritance
▪ Polymorphism is the reason why we want to have inheritance
New Wave Analytica
Polymorphism
▪ Polymorphism allows for “pluggability” or “substitutability”
▪ Types that implement the same interface can substitute for one another
▪ Client code just sees one class, but the actual “concrete” type can be different
in different cases.
New Wave Analytica

More Related Content

PPSX
Intro to Object Oriented Programming with Java
PPSX
Review Session and Attending Java Interviews
PPTX
Session 02 - Elements of Java Language
PPTX
Session 01 - Introduction to Java
PDF
Got bored by the relational database? Switch to a RDF store!
PDF
Java 8 selected updates
PPT
OOP in Java
PPSX
Short notes of oop with java
Intro to Object Oriented Programming with Java
Review Session and Attending Java Interviews
Session 02 - Elements of Java Language
Session 01 - Introduction to Java
Got bored by the relational database? Switch to a RDF store!
Java 8 selected updates
OOP in Java
Short notes of oop with java

What's hot (6)

PPSX
Arrays in Java
PPT
8 oo approach&uml-23_feb
PDF
Yes scala can!
PPT
Presentation on java
PPTX
An Intro to Scala for PHP Developers
PDF
Metaprogramming ruby
Arrays in Java
8 oo approach&uml-23_feb
Yes scala can!
Presentation on java
An Intro to Scala for PHP Developers
Metaprogramming ruby
Ad

Similar to Oriented Programming Concepts and Principles (20)

PDF
Inheritance and interface
PDF
Object-Oriented Programming in Java (Module 1)
PPTX
Introduction to Object Oriented Programming
PDF
Bt8901 objective oriented systems1
PDF
UNIT1- OBJECT ORIENTED PROGRAMMING IN JAVA- AIML IT-SPPU
DOCX
Ooad notes
PPTX
OOP-1.pptx
PPTX
Oop.pptx
PPT
Lukito Edi Nugroho - Object Orientation Concepts
PPTX
CPP Object Oriented Concepts(OOPS).pptx
PPTX
Introduction
PDF
Handout on Object orienetd Analysis and Design
PPTX
Unit 2.pptx
PPTX
Unit 2.pptx
PDF
Programming Laboratory Unit 1.pdf
PPTX
Std 12 computer chapter 6 object oriented concepts (part 1)
PPTX
object oriented programming in c++ introduction lecture 1.pptx
PPT
Oop rosenschein
PPTX
Unit - I Intro. to OOP Concepts and Control Structure -OOP and CG (2024 Patte...
PPTX
[OOP - Lec 02] Why do we need OOP
Inheritance and interface
Object-Oriented Programming in Java (Module 1)
Introduction to Object Oriented Programming
Bt8901 objective oriented systems1
UNIT1- OBJECT ORIENTED PROGRAMMING IN JAVA- AIML IT-SPPU
Ooad notes
OOP-1.pptx
Oop.pptx
Lukito Edi Nugroho - Object Orientation Concepts
CPP Object Oriented Concepts(OOPS).pptx
Introduction
Handout on Object orienetd Analysis and Design
Unit 2.pptx
Unit 2.pptx
Programming Laboratory Unit 1.pdf
Std 12 computer chapter 6 object oriented concepts (part 1)
object oriented programming in c++ introduction lecture 1.pptx
Oop rosenschein
Unit - I Intro. to OOP Concepts and Control Structure -OOP and CG (2024 Patte...
[OOP - Lec 02] Why do we need OOP
Ad

Recently uploaded (20)

PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
KodekX | Application Modernization Development
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
Spectroscopy.pptx food analysis technology
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
sap open course for s4hana steps from ECC to s4
PPTX
Big Data Technologies - Introduction.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
MYSQL Presentation for SQL database connectivity
Digital-Transformation-Roadmap-for-Companies.pptx
KodekX | Application Modernization Development
Dropbox Q2 2025 Financial Results & Investor Presentation
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Spectral efficient network and resource selection model in 5G networks
Reach Out and Touch Someone: Haptics and Empathic Computing
Understanding_Digital_Forensics_Presentation.pptx
NewMind AI Weekly Chronicles - August'25 Week I
Mobile App Security Testing_ A Comprehensive Guide.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Spectroscopy.pptx food analysis technology
Diabetes mellitus diagnosis method based random forest with bat algorithm
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Unlocking AI with Model Context Protocol (MCP)
20250228 LYD VKU AI Blended-Learning.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
sap open course for s4hana steps from ECC to s4
Big Data Technologies - Introduction.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
MYSQL Presentation for SQL database connectivity

Oriented Programming Concepts and Principles

  • 1. Object-Oriented Programming Concepts and Principles New Wave Analytica We Find Solutions in Data
  • 2. Outline ▪ Abstraction ▪ Structured Programming ▪ Procedural vs. Object-Oriented Programming ▪ Goals of Object-Oriented Programming ▪ Principles of Object-Oriented Programming New Wave Analytica
  • 3. Abstraction ▪ One of the prime concepts used to simplify programming problems ▪ Mechanism and practice to reduce and factor out details so that one can focus on a few concepts at a time. ▪ Through the process of abstraction, a programmer hides all but the relevant data about an object in order to reduce complexity and increase efficiency. ▪ Abstraction is one of the key concepts of object-oriented programming (OOP) languages. ▪ Its main goal is to handle complexity by hiding unnecessary details from the user. ▪ That enables the user to implement more complex logic on top of the provided abstraction without understanding or even thinking about all the hidden complexity. New Wave Analytica
  • 5. Structured Programming ▪ Further refinement of procedural programming ▪ Formal methods of planning data flow and functional decomposition ▪ go to is banned
  • 6. Structured Programming ▪ A programming paradigm aimed at improving the clarity, quality, and development time of a computer program by making extensive use of the structured control flow constructs ▪ Selection (if/then/else) ▪ Repetition (while and for) ▪ Block structures ▪ Subroutines ▪ A programming paradigm in contrast to using simple tests and jumps such as the go to statement. New Wave Analytica
  • 7. Procedural Programming ▪ A programming model which is derived from structured programming, based upon the concept of calling procedure. ▪ Procedures, also known as routines, subroutines or functions, simply consist of a series of computational steps to be carried out. ▪ During a program’s execution, any given procedure might be called at any point, including other procedures or itself. ▪ Languages ▪ Basic ▪ Pascal ▪ C New Wave Analytica
  • 8. Procedural Programming ▪ Routines are grouped into functions ▪ A function can call another function ▪ You don’t have to understand each line, lust what each function did ▪ You could hide data to be accessible to only within a function (encapsulation) New Wave Analytica
  • 9. Object-Oriented Programming (OOP) ▪ Takes encapsulation even further by localizing data and associated operations into a mini-program called an object. ▪ An object-oriented program is an ecosystem of objects that interact with each other. ▪ “Think of an object-oriented system as a bunch of intelligent animals as objects inside your machine, talking to each other by sending messages to one another.” – Alllan Holub New Wave Analytica
  • 10. Object-Oriented Programming (OOP) ▪ A programming model which is based upon the concept of objects. ▪ Objects contain data in the form of attributes and code in the form of methods. ▪ In OOP, computer programs are designed using the concept of objects that interact with real world. ▪ OOP languages are various but the most popular ones are class-based, meaning that objects are instances of classes, which also determine their types. ▪ OOP takes abstraction farthest by allowing you to group related data and operations into different types of objects. ▪ You create your own data types, which are types of objects. Each of these data types are called objects. New Wave Analytica
  • 11. Object-Oriented Programming (OOP) ▪ Creating you own classes allows you to design a program so that it is intuitive to remember how it is organized ▪Example ▪ Creating classes that represent real world entities. ▪ Creating classes to have specific responsibilities so that when you need to update a piece of code, you know exactly where to look for it ▪ Languages ▪ Java, C++, C#, Python, PHP, JavaScript ▪ Ruby, Perl, Objective-C, Dart, Swift, Scala New Wave Analytica
  • 12. Goals of Object-Oriented Programming ▪ Comprehensibility ▪ Make it easier for humans to understand you code ▪ Maintainability ▪ Make code easy to modify ▪ Reusability ▪ Old code should be building blocks for new code ▪ Plugability ▪ You can create interchangeable component that can substitute for one another just like machine parts. New Wave Analytica
  • 13. Class and Objects ▪ A class in Java is a blueprint for objects to follow a specific schema defined in the class. ▪ A class defines the behavior for objects of its type. It represents a collection of properties (data and functions) for all its objects. ▪ It supports a template for creating objects which bind code and data. ▪ A class acts as a means to define methods and data. ▪It helps in maintaining access specifications for member variables using access specifiers. New Wave Analytica
  • 14. Class and Objects ▪ An object is the most fundamental entity in Java ▪ Objects represent real-life entities because each of them could have specific behavior, identity, and data (attributes). ▪ In Java, the object is an offspring of its class. ▪ The class has properties to reflect the object state and methods to represent the behavior. ▪ The methods also show an object’s response to other objects. Identity is a unique name for the object assigned by the user, much like variables. New Wave Analytica
  • 15. What is a Class and an Instance of a Class? ▪ Class ▪ Definition of an object ▪ Example: ▪ Your car is a 2018 BMW 3-series ▪ Instance ▪ The created object of a class ▪ Example : ▪ There are many other 2018 BMW 3-series out there but there is only one instance of your car. New Wave Analytica
  • 16. What is an object? ▪ Has attributes ▪ a property or components ▪ Has methods ▪ behaviours or routines New Wave Analytica
  • 17. Example of an Object - Car ▪ Attributes ▪ steering wheel ▪ engine ▪ color ▪ radio ▪ airconditoiner ▪ Methods ▪ go forward ▪ go backward ▪ cool the interior ▪ play music New Wave Analytica
  • 18. What is an interface? ▪ An object has an interface ▪ The outward appearance of an object. How other objects see the object ▪ The attributes and methods that the object exposes. ▪ Normally, an object will only expose some of its attributes and methods. ▪ Some attributes and methods are used by the object itself. Therefore, no other object should have access to those ▪ Some attribute and methods may be made accessible only to certain other objects. ▪ Some attributes and methods may be accessible by any other object New Wave Analytica
  • 19. What is an interface? ▪ Normally, only methods are exposed. Objects usually hide their data to protect then from being changed by other objects without their control ▪ Constants are an exception. These don’t change anyway New Wave Analytica
  • 20. Three Core Principles of OOP ▪ Encapsulation ▪ Inheritance ▪ Polymorphism New Wave Analytica
  • 21. Encapsulation ▪ It is a mechanism of wrapping the data (variables) and code acting on the data (methods) together as a single unit. ▪ In encapsulation, the variables of a class will be hidden from other classes, and can be accessed only through the methods of their current class. ▪ Grouping of data and operations into objects. ▪ Related data and operations should not be separated. They should be found in a single object. ▪ It is also known as data hiding New Wave Analytica
  • 22. Encapsulation ▪To achieve encapsulation in Java ▪ Declare the variables of a class as private. ▪ Provide public setter and getter methods to modify and view the variables values. ▪ Benefits of Encapsulation ▪ The fields of a class can be made read-only or write-only ▪ A class can have total control over what is stored in its fields ▪ Simpler interfaces ▪ Only a few methods are exposed to other objects. Since interactions between objects are simple, system us easier for the programmer to comprehend. ▪ Data protected from corruption ▪ Easier to modify code or find bugs ▪ Simpler interactions New Wave Analytica
  • 23. Examples of Encapsulation ▪ You shouldn’t have to ask someone with radar gun to measure the speed of your car. Your car should have its own speedometer. ▪ Purchase Order Object ▪ Data for purchase orders should not be lumped in the same objects as data for invoices and receipts ▪ The methods for retrieving data from a purchase order should not be found in a separate class from the data. ▪ DB Connection Object ▪ The DB Connection object should not need to look up the URL from the database from another object every time its does an operation. New Wave Analytica
  • 24. Examples of Encapsulation ▪ Information Hiding ▪ AN object should expose only what is necessary, and only at the appropriate level. ▪ Think of CIA … “need-to-know” New Wave Analytica
  • 25. Examples of Encapsulation ▪ Car ▪ Driver : Only steering wheel, pedals, and stick shift are exposed. Driver should not access engire or gears or axle to drive the car ▪ Mechanic ▪ Access to engine, gears, etc., but not internals of each part ▪Manufacturer ▪ Access to internals of each part New Wave Analytica
  • 26. Examples of Encapsulation ▪ Purchase Order Object ▪ Any object can get into from the object, but only certain objects should have authority to set information. ▪ Only certain objects should be allowed to create PO object ▪ DB Connection Object ▪ Only the Driver Manager object can create a connection ▪ Users cannot set whether a connection is read-only or not. New Wave Analytica
  • 27. Inheritance ▪ It is a way to create a new class by deriving from another class. ▪ It is the mechanism in java by which one class is allowed to inherit the features(fields and methods) of another class. ▪ Interface Inheritance ▪ The new class acquires the interface of the old class ▪ Implementation Inheritance ▪ The new class often also acquires the implementation of the old class ▪ The new class can change the implementation of the older class or ass its methods and attributes. New Wave Analytica
  • 28. Inheritance ▪ Inheritance is a way to allow objects to share code, preventing code- duplication ▪ Code supplication is the number sin in OOP ▪ Implementation inheritance is dangerous ▪ The Fragile Base Class Problem ▪ A subclass must inherit all inheritable members of the superclass ▪ No option to disinherit a member ▪ If the subclass inherits members that it doesn’t need, those members might be called by other objects in a way that the creator of the subclass did not intend (remember you’re working in a tem) causing undesirable behavior
  • 29. Polymorphism ▪ When a single data type exhibits different behaviours during execution. ▪ Greek : Poly means “many”, morph means “form” ▪ Polymorphism means “existing in many forms” ▪ It is the other side of the same coin as inheritance ▪ Polymorphism is the reason why we want to have inheritance New Wave Analytica
  • 30. Polymorphism ▪ Polymorphism allows for “pluggability” or “substitutability” ▪ Types that implement the same interface can substitute for one another ▪ Client code just sees one class, but the actual “concrete” type can be different in different cases. New Wave Analytica