SlideShare a Scribd company logo
1 of 30
Download to read offline
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

What's hot

8 oo approach&uml-23_feb
8 oo approach&uml-23_feb8 oo approach&uml-23_feb
8 oo approach&uml-23_febRaj Shah
 
An Intro to Scala for PHP Developers
An Intro to Scala for PHP DevelopersAn Intro to Scala for PHP Developers
An Intro to Scala for PHP DevelopersHuffPost Code
 

What's hot (6)

Arrays in Java
Arrays in Java Arrays in Java
Arrays in Java
 
8 oo approach&uml-23_feb
8 oo approach&uml-23_feb8 oo approach&uml-23_feb
8 oo approach&uml-23_feb
 
Yes scala can!
Yes scala can!Yes scala can!
Yes scala can!
 
Presentation on java
Presentation  on  javaPresentation  on  java
Presentation on java
 
An Intro to Scala for PHP Developers
An Intro to Scala for PHP DevelopersAn Intro to Scala for PHP Developers
An Intro to Scala for PHP Developers
 
Metaprogramming ruby
Metaprogramming rubyMetaprogramming ruby
Metaprogramming ruby
 

Similar to Oriented Programming Concepts and Principles

object oriented programing lecture 1
object oriented programing lecture 1object oriented programing lecture 1
object oriented programing lecture 1Geophery sanga
 
PHP OOP Lecture - 01.pptx
PHP OOP Lecture - 01.pptxPHP OOP Lecture - 01.pptx
PHP OOP Lecture - 01.pptxAtikur Rahman
 
CPP-Unit 1.pptx
CPP-Unit 1.pptxCPP-Unit 1.pptx
CPP-Unit 1.pptxYashKoli22
 
22601221182_RAHUL_MODAK_BCAC301.pdf
22601221182_RAHUL_MODAK_BCAC301.pdf22601221182_RAHUL_MODAK_BCAC301.pdf
22601221182_RAHUL_MODAK_BCAC301.pdfssuser736e06
 
Introduction to OOP concepts
Introduction to OOP conceptsIntroduction to OOP concepts
Introduction to OOP conceptsAhmed Farag
 
Fundamentals of OOP (Object Oriented Programming)
Fundamentals of OOP (Object Oriented Programming)Fundamentals of OOP (Object Oriented Programming)
Fundamentals of OOP (Object Oriented Programming)MD Sulaiman
 
Need of object oriented programming
Need of object oriented programmingNeed of object oriented programming
Need of object oriented programmingAmar Jukuntla
 
Object Oriented Programming All Unit Notes
Object Oriented Programming All Unit NotesObject Oriented Programming All Unit Notes
Object Oriented Programming All Unit NotesBalamuruganV28
 
U1 JAVA.pptx
U1 JAVA.pptxU1 JAVA.pptx
U1 JAVA.pptxmadan r
 
Concepts of OOPs
Concepts of OOPsConcepts of OOPs
Concepts of OOPsEssay Corp
 
C++ in object oriented programming
C++ in object oriented programmingC++ in object oriented programming
C++ in object oriented programmingSaket Khopkar
 
lecture-1111111111111111111111111111.pdf
lecture-1111111111111111111111111111.pdflecture-1111111111111111111111111111.pdf
lecture-1111111111111111111111111111.pdfharey68956
 
2CPP09 - Encapsulation
2CPP09 - Encapsulation2CPP09 - Encapsulation
2CPP09 - EncapsulationMichael Heron
 
SAP ABAP using OOPS - JH Softech
SAP ABAP using OOPS - JH SoftechSAP ABAP using OOPS - JH Softech
SAP ABAP using OOPS - JH SoftechVikram P Madduri
 

Similar to Oriented Programming Concepts and Principles (20)

Oops in Java
Oops in JavaOops in Java
Oops in Java
 
object oriented programing lecture 1
object oriented programing lecture 1object oriented programing lecture 1
object oriented programing lecture 1
 
Oop java Concept
Oop java ConceptOop java Concept
Oop java Concept
 
PHP OOP Lecture - 01.pptx
PHP OOP Lecture - 01.pptxPHP OOP Lecture - 01.pptx
PHP OOP Lecture - 01.pptx
 
CPP-Unit 1.pptx
CPP-Unit 1.pptxCPP-Unit 1.pptx
CPP-Unit 1.pptx
 
Principles of OOPs.pptx
Principles of OOPs.pptxPrinciples of OOPs.pptx
Principles of OOPs.pptx
 
22601221182_RAHUL_MODAK_BCAC301.pdf
22601221182_RAHUL_MODAK_BCAC301.pdf22601221182_RAHUL_MODAK_BCAC301.pdf
22601221182_RAHUL_MODAK_BCAC301.pdf
 
Introduction to OOP concepts
Introduction to OOP conceptsIntroduction to OOP concepts
Introduction to OOP concepts
 
80410172053.pdf
80410172053.pdf80410172053.pdf
80410172053.pdf
 
Fundamentals of OOP (Object Oriented Programming)
Fundamentals of OOP (Object Oriented Programming)Fundamentals of OOP (Object Oriented Programming)
Fundamentals of OOP (Object Oriented Programming)
 
Need of object oriented programming
Need of object oriented programmingNeed of object oriented programming
Need of object oriented programming
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Object Oriented Programming All Unit Notes
Object Oriented Programming All Unit NotesObject Oriented Programming All Unit Notes
Object Oriented Programming All Unit Notes
 
U1 JAVA.pptx
U1 JAVA.pptxU1 JAVA.pptx
U1 JAVA.pptx
 
Concepts of OOPs
Concepts of OOPsConcepts of OOPs
Concepts of OOPs
 
C++ in object oriented programming
C++ in object oriented programmingC++ in object oriented programming
C++ in object oriented programming
 
OOP-1.pptx
OOP-1.pptxOOP-1.pptx
OOP-1.pptx
 
lecture-1111111111111111111111111111.pdf
lecture-1111111111111111111111111111.pdflecture-1111111111111111111111111111.pdf
lecture-1111111111111111111111111111.pdf
 
2CPP09 - Encapsulation
2CPP09 - Encapsulation2CPP09 - Encapsulation
2CPP09 - Encapsulation
 
SAP ABAP using OOPS - JH Softech
SAP ABAP using OOPS - JH SoftechSAP ABAP using OOPS - JH Softech
SAP ABAP using OOPS - JH Softech
 

Recently uploaded

Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 

Recently uploaded (20)

Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 

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