SlideShare une entreprise Scribd logo
1  sur  42
Disclaimer: This presentation is prepared by trainees of baabtra as a part of
mentoring program. This is not official document of baabtra – Mentoring
Partner
baabtra – Mentoring Partner is the mentoring division of baabte System Technologies Pvt. Ltd
Object Oriented Programming
           (OOP)
                Arjun P Ajay
Pop-Procedure Oriented
Programming Language(Structured
programming)

• Structured programming is based around data structures and
  subroutines
• The subroutines are where stuff actually "happens"
• data structures are simply containers for the information
  needed by those subroutines.
POP can be briefly summarized as
• No code reusability. Hence time to develop
  the software and debugging increase.
• As Length of application increases, the
  programmer loses control over it.
• software designers tend to use Top-Down approach,
  in which the overall objective of the system is
  defined first.
• Then the system is divided into various sub tasks or
  sub modules.
• With this methodology, software development is
  done by writing a set of sub programs, called
  functions that can be integrated together to form a
  complex system.
What is oop
What is oop



              OOP allow decomposition of program into a
              number of entities called objects .

              Build data and functions around these objects.

              Object consist of data and function.

              The data of an object can be accessed only by
              the functions associated with that object
What is OOP?


• Objects can be used effectively to represent
  real-world entities
• An object oriented program may be
  considered a collection interacting object.
• Each object is capable of sending and
  receiving messages and processing data
Object oriented programming
concepts
•   Object
•   Class
•   Data Abstraction
•   Modularity
•   Delegation
•   Encapsulation
•   Polymorphism
•   Inheritance
Class
• A class is the blueprint of an object
• Multiple objects can be created from the same class
• Class is a collection of member data and member
  functions.
• Objects contain data and code to manipulate that
  data.
• The entire set of data and code of an object can be
  made a user-defined data type with the help of a
  class.
Class members
• Namespace: The namespace is a keyword that
  defines a distinctive name or last name for the
  class.
• Class declaration: Line of code where the class
  name and type are defined.
• Fields: Set of variables declared in a class block.
• Constants: Set of constants declared in a class
  block.
• Constructors: A method or group of methods that
  contains code to initialize the class.
• Properties: The set of descriptive data of an
  object.
• Events: Program responses that get fired after
  a user or application action.
• Methods: Set of functions of the class.
• Destructor: A method that is called when the
  class is destroyed
Access keywords
• Access keywords define the access to class members from the
  same class and from other classes
• Public: Access to the class member from any other class.
  Accessible from outside of the class & assembly
–     It can access from anywhere
–     There is no restriction on accessibility
• Private: Access to the class member only in the same class.
• Protected: Allows access to the class member only within the
  same class and from inherited classes. Accessible within class
  & sub-classes
• Internal: Allows access to the class member only in the same
  assembly.
• Protected internal: Allows access to the class member only
  within the same class, from inherited classes
'Imported namespaces
 Imports System
' Namespace: Consider using CompanyName.Product.ComponentType
 Namespace DotNetTreats.OOSE.OOP_VBNET
'Class declaration
 Public Class employee
'Fields
Private _name As String
Private _salary As Integer
'Constants
Private Const anualBonus As Integer = 1000
'Constructors
Public Sub New()
MyBase.New()
End Sub
'Properties
Public Property Name() As String
Get
Return _name
End Get
Set(ByVal Value As String)
_name = value
End Set
End Property
Public Property Salary() As Integer
Get
Return _salary
End Get
Set(ByVal Value As Integer)
_salary = value
End Set
End Property
' Event handlers
Public Event OnPromotion As EventHandler
'Methods
Public Sub DuplicateSalary()
_salary = (_salary * 2)
End Sub
End Class
End Namespace


ByVal is short for "By Value"
*it means is that you are passing a copy of a variable to your Subroutine.
* You can make changes to the copy and the original will not be altered.

ByRef short for By Reference
*you are not handing over a copy of the original variable but pointing to the
   original variable.
Objects                         An object is anything that really
                                  exists in the world and can be
                                  distinguished from others
Every object has properties and
can perform certain actions
These properties are represented
by variables in programming and
actions are performed by methods
(functions). So an object contains
variables and methods         Objects are the building
                            blocks of OOP and are
                            commonly defined as
                            variables or data structures
Object composition

• Object identity: Means that every object is
  unique and can be differentiated from other
  objects. Each time and object is created
  (instantiated) the object identity is defined.
• Object behavior: What the object can do. In OOP,
  methods work as functions that define the set of
  actions that the object can do.
• Object state: The data stored within the object at
  any given moment. In OOP, fields, constants, and
  properties define the state of an object.
Structures
  Not everything in the real world should be
  represented as a class.
• Structures are suitable to represent lightweight
  objects.
• Structures can have methods and properties and are
  useful for
• defining types that act as user-defined primitive
Encapsulation
• The wrapping up of data and functions into a single unit
  (called class) is known as encapsulation.
• In OOP we are capsuling our code not in a shell but in
  "Objects" & "Classes".
• It hides all the internal details of an object from the outside
  world
• It hides its data and methods from outside the world and only
  expose data and methods that are required.
• It provides us maintainability, flexibility and extensibility to
  our code.
• Encapsulation allows developers to build objects that can be
  changed without affecting the client code that uses them
• The data is not accessible to the outside world and
  only those functions which are wrapped in the class
  can access it.
• These functions provide the interface between the
  object's data and the program.
• This insulation of the data from direct access by the
  program is called data hiding.
Data Abstraction
• “The process of identifying common patterns that
  have systematic variations; an abstraction represents
  the common pattern and provides a means for
  specifying which variation to use"
• An abstract class is a parent class that allows
  inheritance but can never be instantiated
• Abstract classes contain one or more abstract
  methods that do not have implementation.
• Abstract classes allow specialization of inherited
  classes.
Data Abstraction contn…
• Abstraction is a powerful means to tackle the complexity of
  programming by wrapping up and thus reducing the
  complexity of complex operations.
• In this it display only the features that needed the user, and
  hide all other data
• Through Abstraction all relevant data can be hide in order to
  reduce complexity and increase efficiency
Polymorphism
• Its the property in which a single object can take more than one
    form.
• Single interface & multiple method is called polymorphism.
• Polymorphism allows objects to be represented in multiple forms.
• Polymorphism is a concept linked to inheritance and assures that
    derived class have the same function even though each derived
    class performs different operations
Ex:
• Function overloading (Static polymorphism / early binding).
• Function overriding (dynamic polymorphism / late binding).

• Polymorphism allows a client to treat different objects in the same
  way even if they were created from different classes and exhibit
  different behaviors.
Polymorphism
• Method Overloading
- Method with same name but with different arguments
  is called method overloading.
-     Method     Overloading    forms   compile-time
  polymorphism.

• Method Overriding
- Method overriding occurs when child class declares a
   method that has the same type arguments as a
   method declared by one of its super class.
- Method overriding forms Run-time polymorphism.
• Modularity
-The modularity of object-oriented programming
  means that the valid components of a big
  program can each be implemented individually.
-Different people can work on various classes.
-Each execution task is isolated from the others.
-A ``module'' is nothing more than a file containing
  source code.
      - Breaking a large (or even not-so-large)
  program into different files is a convenient way of
  splitting it into manageable pieces.
    -Each piece can be worked on independently
  and compiled alone, then integrated with other
  pieces when the program is linked
Delegation
   Delegation allows the behavior of an object to be defined
   in terms of the behavior of another object.
  ie , Delegation is alternative to class inheritance.
• Delegation is a way of making object composition
   as powerful as inheritance.
• In delegation, two objects are involved in handling a
   request:
   -A receiving object delegates operations to its delegate.
   -This is analogous to the child classes sending requests to
   the parent classes.
• When an object receives a request, the object can
  either handle the request itself or pass the request
  on to a second object to do the work.
• If the object decides to pass the request on, you say
  that the object has forwarded responsibility for
  handling the request to the second object.
Inheritance
• Inheritance is the property in which, a derived
  class acquires the attributes of its base class.
• you can create or 'inherit' your own class (derived
  class), using an existing class (base class). You can
  use the Inherits keyword for this.
• In OOP, a parent class can inherit its behavior and
  state to children classes.
• This concept was developed to manage
  generalization and specialization in OOP and is
  represented by a is-a relationship.
*The concept of generalization in OOP means that an object
encapsulates common state an behavior for a category of
objects.
*The general object in this sample is the geometric shape.
*Most geometric shapes have area, perimeter, and color.
*The concept of specialization in OOP means that an object
can inherit the common state and behavior of a generic
object;
however, each object needs to define its own special and
particular state an behavior
The Shape class is the
parent             class.
Square, Rectangle, and
Circle are derived
classes that inherit
from      Shape.      The
triangle-connector in
the diagram represents
an is-a relationship.
Imports System
Class Human
'This is something that all humans do
 Public Sub Walk()
 Console.Writeline ("Walking")
 End Sub End Class
‘A Programmer is a Human
Class Programmer
Inherits Human
 'We already have the above Walk() function
'This is something that all programmers do ;)
Public Sub StealCode()
Console.Writeline ("Stealing code")
End Sub
End Class
• Example Program for class
Public Class Example
Private _value As Integer
  Public Sub New()
    _value = 2
  End Sub

  Public Function Value() As Integer
   Return _value * 2
  End Function
End Class

Module Module1
  Sub Main()
   Dim x As Example = New Example()
   Console.WriteLine (x.Value())
  End Sub
End Module -----------(out put =4)
•   Program that uses Inherits keyword [VB.NET]

Class A
  Public _value As Integer

  Public Sub Display()
   Console.WriteLine(_value)
  End Sub
End Class

Class B : Inherits A
  Public Sub New(ByVal value As Integer)
    MyBase._value = value
  End Sub
End Class

Class C : Inherits A
  Public Sub New(ByVal value As Integer)
    MyBase._value = value * 2
  End Sub
End Class
Module Module1
 Sub Main()
  Dim b As B = New B(5)
  b.Display()

   Dim c As C = New C(5)
   c.Display()
  End Sub
End Module
• Imports System
public Class Circle
  Public Radius As Double
   Public Function CalculateDiameter() As Double
    Return Radius * 2
  End Function

  Public Function CalculateCircmuference() As Double
    Return CalculateDiameter() * 3.14159
  End Function

  Public Function CalculateArea() As Double
    Return Radius * Radius * 3.14159
  End Function
End Class
Public Class Exercise
  Public Sub Main()
    Dim circ As Circle = New Circle
    circ.Radius = 25.84
    Console.WriteLine(" -=- Circle Characteristics -=-")
    Console.WriteLine("Radius: {0} ", circ.Radius)
    Console.WriteLine("Diameter:{0} ",circ.CalculateDiameter())
  Console.WriteLine("Circumference:{0}
  ", circ.CalculateCircmuference())
    Console.WriteLine("Area: {0} " & vbCrLf, circ.CalculateArea())
  End Sub
End Class
• Result
• -=- Circle Characteristics -=-
Radius :        25.55
Diameter :      51.1
Circumference: 160.535249
Area :          2050.837805975
• Advantages of OOP
  Object-Oriented Programming has the following
  advantages over conventional approaches:

• OOP provides a clear modular structure for programs which
  makes it good for defining abstract data types where
  implementation details are hidden and the unit has a
  clearly defined interface.

• OOP makes it easy to maintain and modify existing code as
  new objects can be created with small differences to
  existing ones.

• OOP provides a good framework for code libraries where
  supplied software components can be easily adapted and
  modified by the programmer. This is particularly useful for
  developing graphical user interfaces.
Thank You
Contact Us

Contenu connexe

Tendances

Tendances (20)

Introduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingIntroduction to Object Oriented Programming
Introduction to Object Oriented Programming
 
Object Oriented Paradigm
Object Oriented ParadigmObject Oriented Paradigm
Object Oriented Paradigm
 
Python Functions
Python   FunctionsPython   Functions
Python Functions
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)
 
Object Oriented Design
Object Oriented DesignObject Oriented Design
Object Oriented Design
 
Polymorphism in oop
Polymorphism in oopPolymorphism in oop
Polymorphism in oop
 
OOP Introduction with java programming language
OOP Introduction with java programming languageOOP Introduction with java programming language
OOP Introduction with java programming language
 
Introduction to oop
Introduction to oop Introduction to oop
Introduction to oop
 
Ooad ppt
Ooad pptOoad ppt
Ooad ppt
 
class and objects
class and objectsclass and objects
class and objects
 
Advance oops concepts
Advance oops conceptsAdvance oops concepts
Advance oops concepts
 
Variables in python
Variables in pythonVariables in python
Variables in python
 
OOP - Benefits and advantages of OOP
OOP - Benefits and advantages of OOPOOP - Benefits and advantages of OOP
OOP - Benefits and advantages of OOP
 
C# Tutorial
C# Tutorial C# Tutorial
C# Tutorial
 
Characteristics of OOPS
Characteristics of OOPS Characteristics of OOPS
Characteristics of OOPS
 
Introduction to c#
Introduction to c#Introduction to c#
Introduction to c#
 
C# classes objects
C#  classes objectsC#  classes objects
C# classes objects
 
Object-oriented concepts
Object-oriented conceptsObject-oriented concepts
Object-oriented concepts
 
Array in c++
Array in c++Array in c++
Array in c++
 
Oop c++class(final).ppt
Oop c++class(final).pptOop c++class(final).ppt
Oop c++class(final).ppt
 

En vedette

itft-Fundamentals of object–oriented programming in java
itft-Fundamentals of object–oriented programming in javaitft-Fundamentals of object–oriented programming in java
itft-Fundamentals of object–oriented programming in javaAtul Sehdev
 
Object oriented fundamentals_in_java
Object oriented fundamentals_in_javaObject oriented fundamentals_in_java
Object oriented fundamentals_in_javaSelf
 
OOP - Understanding association, aggregation, composition and dependency
OOP - Understanding association, aggregation, composition and dependencyOOP - Understanding association, aggregation, composition and dependency
OOP - Understanding association, aggregation, composition and dependencyMudasir Qazi
 
Chapter1 - Introduction to Object-Oriented Programming and Software Development
Chapter1 - Introduction to Object-Oriented Programming and Software DevelopmentChapter1 - Introduction to Object-Oriented Programming and Software Development
Chapter1 - Introduction to Object-Oriented Programming and Software DevelopmentEduardo Bergavera
 
Advanced Python : Static and Class Methods
Advanced Python : Static and Class Methods Advanced Python : Static and Class Methods
Advanced Python : Static and Class Methods Bhanwar Singh Meena
 
[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member Functions[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member FunctionsMuhammad Hammad Waseem
 
Introduction to oops concepts
Introduction to oops conceptsIntroduction to oops concepts
Introduction to oops conceptsNilesh Dalvi
 
Introduction to Object-Oriented Programming & Design Principles (TCF 2014)
Introduction to Object-Oriented Programming & Design Principles (TCF 2014)Introduction to Object-Oriented Programming & Design Principles (TCF 2014)
Introduction to Object-Oriented Programming & Design Principles (TCF 2014)Michael Redlich
 
Need of object oriented programming
Need of object oriented programmingNeed of object oriented programming
Need of object oriented programmingAmar Jukuntla
 
Basic concepts of object oriented programming
Basic concepts of object oriented programmingBasic concepts of object oriented programming
Basic concepts of object oriented programmingSachin Sharma
 
The Successful Job Interview
The Successful Job InterviewThe Successful Job Interview
The Successful Job Interviewsuweb
 

En vedette (16)

itft-Fundamentals of object–oriented programming in java
itft-Fundamentals of object–oriented programming in javaitft-Fundamentals of object–oriented programming in java
itft-Fundamentals of object–oriented programming in java
 
Chap 6(decision making-looping)
Chap 6(decision making-looping)Chap 6(decision making-looping)
Chap 6(decision making-looping)
 
Object oriented fundamentals_in_java
Object oriented fundamentals_in_javaObject oriented fundamentals_in_java
Object oriented fundamentals_in_java
 
OOP - Understanding association, aggregation, composition and dependency
OOP - Understanding association, aggregation, composition and dependencyOOP - Understanding association, aggregation, composition and dependency
OOP - Understanding association, aggregation, composition and dependency
 
Chapter1 - Introduction to Object-Oriented Programming and Software Development
Chapter1 - Introduction to Object-Oriented Programming and Software DevelopmentChapter1 - Introduction to Object-Oriented Programming and Software Development
Chapter1 - Introduction to Object-Oriented Programming and Software Development
 
Advanced Python : Static and Class Methods
Advanced Python : Static and Class Methods Advanced Python : Static and Class Methods
Advanced Python : Static and Class Methods
 
[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member Functions[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member Functions
 
Introduction to oops concepts
Introduction to oops conceptsIntroduction to oops concepts
Introduction to oops concepts
 
Introduction to Object-Oriented Programming & Design Principles (TCF 2014)
Introduction to Object-Oriented Programming & Design Principles (TCF 2014)Introduction to Object-Oriented Programming & Design Principles (TCF 2014)
Introduction to Object-Oriented Programming & Design Principles (TCF 2014)
 
Need of object oriented programming
Need of object oriented programmingNeed of object oriented programming
Need of object oriented programming
 
Object-Oriented Programming Using C++
Object-Oriented Programming Using C++Object-Oriented Programming Using C++
Object-Oriented Programming Using C++
 
Hydraulic Ram
Hydraulic RamHydraulic Ram
Hydraulic Ram
 
Uml - An Overview
Uml - An OverviewUml - An Overview
Uml - An Overview
 
Basic concepts of object oriented programming
Basic concepts of object oriented programmingBasic concepts of object oriented programming
Basic concepts of object oriented programming
 
The Successful Job Interview
The Successful Job InterviewThe Successful Job Interview
The Successful Job Interview
 
Introduction to UML
Introduction to UMLIntroduction to UML
Introduction to UML
 

Similaire à Object oriented programming

Introduction to OOP concepts
Introduction to OOP conceptsIntroduction to OOP concepts
Introduction to OOP conceptsAhmed Farag
 
Object oriented programming 6 oop with c++
Object oriented programming 6  oop with c++Object oriented programming 6  oop with c++
Object oriented programming 6 oop with c++Vaibhav Khanna
 
L1-Introduction to OOPs concepts.pdf
L1-Introduction to OOPs concepts.pdfL1-Introduction to OOPs concepts.pdf
L1-Introduction to OOPs concepts.pdfBhanuJatinSingh
 
CPP-Unit 1.pptx
CPP-Unit 1.pptxCPP-Unit 1.pptx
CPP-Unit 1.pptxYashKoli22
 
SKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPTSKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPTSkillwise Group
 
object oriented programing lecture 1
object oriented programing lecture 1object oriented programing lecture 1
object oriented programing lecture 1Geophery sanga
 
Object Oriented Programming Tutorial.pptx
Object Oriented Programming Tutorial.pptxObject Oriented Programming Tutorial.pptx
Object Oriented Programming Tutorial.pptxethiouniverse
 
1 unit (oops)
1 unit (oops)1 unit (oops)
1 unit (oops)Jay Patel
 
8 oo approach&uml-23_feb
8 oo approach&uml-23_feb8 oo approach&uml-23_feb
8 oo approach&uml-23_febRaj Shah
 
Principles and advantages of oop ppt
Principles and advantages of oop pptPrinciples and advantages of oop ppt
Principles and advantages of oop pptdaxesh chauhan
 
Introduction to oop
Introduction to oopIntroduction to oop
Introduction to oopcolleges
 

Similaire à Object oriented programming (20)

Principles of OOPs.pptx
Principles of OOPs.pptxPrinciples of OOPs.pptx
Principles of OOPs.pptx
 
Introduction to OOP concepts
Introduction to OOP conceptsIntroduction to OOP concepts
Introduction to OOP concepts
 
Object oriented programming 6 oop with c++
Object oriented programming 6  oop with c++Object oriented programming 6  oop with c++
Object oriented programming 6 oop with c++
 
L1-Introduction to OOPs concepts.pdf
L1-Introduction to OOPs concepts.pdfL1-Introduction to OOPs concepts.pdf
L1-Introduction to OOPs concepts.pdf
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
CPP-Unit 1.pptx
CPP-Unit 1.pptxCPP-Unit 1.pptx
CPP-Unit 1.pptx
 
Basic concepts of oops
Basic concepts of oopsBasic concepts of oops
Basic concepts of oops
 
SKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPTSKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPT
 
Lecture 5.pptx
Lecture 5.pptxLecture 5.pptx
Lecture 5.pptx
 
object oriented programing lecture 1
object oriented programing lecture 1object oriented programing lecture 1
object oriented programing lecture 1
 
Object Oriented Programming Tutorial.pptx
Object Oriented Programming Tutorial.pptxObject Oriented Programming Tutorial.pptx
Object Oriented Programming Tutorial.pptx
 
1 unit (oops)
1 unit (oops)1 unit (oops)
1 unit (oops)
 
Introduction
IntroductionIntroduction
Introduction
 
8 oo approach&uml-23_feb
8 oo approach&uml-23_feb8 oo approach&uml-23_feb
8 oo approach&uml-23_feb
 
Java unit 7
Java unit 7Java unit 7
Java unit 7
 
Principles and advantages of oop ppt
Principles and advantages of oop pptPrinciples and advantages of oop ppt
Principles and advantages of oop ppt
 
80410172053.pdf
80410172053.pdf80410172053.pdf
80410172053.pdf
 
Oops concepts
Oops conceptsOops concepts
Oops concepts
 
Introduction to oop
Introduction to oopIntroduction to oop
Introduction to oop
 
C# by Zaheer Abbas Aghani
C# by Zaheer Abbas AghaniC# by Zaheer Abbas Aghani
C# by Zaheer Abbas Aghani
 

Plus de baabtra.com - No. 1 supplier of quality freshers

Plus de baabtra.com - No. 1 supplier of quality freshers (20)

Agile methodology and scrum development
Agile methodology and scrum developmentAgile methodology and scrum development
Agile methodology and scrum development
 
Best coding practices
Best coding practicesBest coding practices
Best coding practices
 
Core java - baabtra
Core java - baabtraCore java - baabtra
Core java - baabtra
 
Acquiring new skills what you should know
Acquiring new skills   what you should knowAcquiring new skills   what you should know
Acquiring new skills what you should know
 
Baabtra.com programming at school
Baabtra.com programming at schoolBaabtra.com programming at school
Baabtra.com programming at school
 
99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love 99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love
 
Php sessions & cookies
Php sessions & cookiesPhp sessions & cookies
Php sessions & cookies
 
Php database connectivity
Php database connectivityPhp database connectivity
Php database connectivity
 
Chapter 6 database normalisation
Chapter 6  database normalisationChapter 6  database normalisation
Chapter 6 database normalisation
 
Chapter 5 transactions and dcl statements
Chapter 5  transactions and dcl statementsChapter 5  transactions and dcl statements
Chapter 5 transactions and dcl statements
 
Chapter 4 functions, views, indexing
Chapter 4  functions, views, indexingChapter 4  functions, views, indexing
Chapter 4 functions, views, indexing
 
Chapter 3 stored procedures
Chapter 3 stored proceduresChapter 3 stored procedures
Chapter 3 stored procedures
 
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
Chapter 2  grouping,scalar and aggergate functions,joins   inner join,outer joinChapter 2  grouping,scalar and aggergate functions,joins   inner join,outer join
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Microsoft holo lens
Microsoft holo lensMicrosoft holo lens
Microsoft holo lens
 
Blue brain
Blue brainBlue brain
Blue brain
 
5g
5g5g
5g
 
Aptitude skills baabtra
Aptitude skills baabtraAptitude skills baabtra
Aptitude skills baabtra
 
Gd baabtra
Gd baabtraGd baabtra
Gd baabtra
 

Dernier

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 

Dernier (20)

TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 

Object oriented programming

  • 1.
  • 2. Disclaimer: This presentation is prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra – Mentoring Partner baabtra – Mentoring Partner is the mentoring division of baabte System Technologies Pvt. Ltd
  • 3. Object Oriented Programming (OOP) Arjun P Ajay
  • 4. Pop-Procedure Oriented Programming Language(Structured programming) • Structured programming is based around data structures and subroutines • The subroutines are where stuff actually "happens" • data structures are simply containers for the information needed by those subroutines.
  • 5. POP can be briefly summarized as • No code reusability. Hence time to develop the software and debugging increase. • As Length of application increases, the programmer loses control over it.
  • 6. • software designers tend to use Top-Down approach, in which the overall objective of the system is defined first. • Then the system is divided into various sub tasks or sub modules. • With this methodology, software development is done by writing a set of sub programs, called functions that can be integrated together to form a complex system.
  • 8. What is oop OOP allow decomposition of program into a number of entities called objects . Build data and functions around these objects. Object consist of data and function. The data of an object can be accessed only by the functions associated with that object
  • 9. What is OOP? • Objects can be used effectively to represent real-world entities • An object oriented program may be considered a collection interacting object. • Each object is capable of sending and receiving messages and processing data
  • 10. Object oriented programming concepts • Object • Class • Data Abstraction • Modularity • Delegation • Encapsulation • Polymorphism • Inheritance
  • 11. Class • A class is the blueprint of an object • Multiple objects can be created from the same class • Class is a collection of member data and member functions. • Objects contain data and code to manipulate that data. • The entire set of data and code of an object can be made a user-defined data type with the help of a class.
  • 12. Class members • Namespace: The namespace is a keyword that defines a distinctive name or last name for the class. • Class declaration: Line of code where the class name and type are defined. • Fields: Set of variables declared in a class block. • Constants: Set of constants declared in a class block. • Constructors: A method or group of methods that contains code to initialize the class.
  • 13. • Properties: The set of descriptive data of an object. • Events: Program responses that get fired after a user or application action. • Methods: Set of functions of the class. • Destructor: A method that is called when the class is destroyed
  • 14. Access keywords • Access keywords define the access to class members from the same class and from other classes • Public: Access to the class member from any other class. Accessible from outside of the class & assembly – It can access from anywhere – There is no restriction on accessibility • Private: Access to the class member only in the same class. • Protected: Allows access to the class member only within the same class and from inherited classes. Accessible within class & sub-classes • Internal: Allows access to the class member only in the same assembly. • Protected internal: Allows access to the class member only within the same class, from inherited classes
  • 15. 'Imported namespaces Imports System ' Namespace: Consider using CompanyName.Product.ComponentType Namespace DotNetTreats.OOSE.OOP_VBNET 'Class declaration Public Class employee 'Fields Private _name As String Private _salary As Integer 'Constants Private Const anualBonus As Integer = 1000 'Constructors Public Sub New() MyBase.New() End Sub
  • 16. 'Properties Public Property Name() As String Get Return _name End Get Set(ByVal Value As String) _name = value End Set End Property Public Property Salary() As Integer Get Return _salary End Get Set(ByVal Value As Integer) _salary = value End Set End Property
  • 17. ' Event handlers Public Event OnPromotion As EventHandler 'Methods Public Sub DuplicateSalary() _salary = (_salary * 2) End Sub End Class End Namespace ByVal is short for "By Value" *it means is that you are passing a copy of a variable to your Subroutine. * You can make changes to the copy and the original will not be altered. ByRef short for By Reference *you are not handing over a copy of the original variable but pointing to the original variable.
  • 18. Objects An object is anything that really exists in the world and can be distinguished from others Every object has properties and can perform certain actions These properties are represented by variables in programming and actions are performed by methods (functions). So an object contains variables and methods Objects are the building blocks of OOP and are commonly defined as variables or data structures
  • 19. Object composition • Object identity: Means that every object is unique and can be differentiated from other objects. Each time and object is created (instantiated) the object identity is defined. • Object behavior: What the object can do. In OOP, methods work as functions that define the set of actions that the object can do. • Object state: The data stored within the object at any given moment. In OOP, fields, constants, and properties define the state of an object.
  • 20. Structures Not everything in the real world should be represented as a class. • Structures are suitable to represent lightweight objects. • Structures can have methods and properties and are useful for • defining types that act as user-defined primitive
  • 21. Encapsulation • The wrapping up of data and functions into a single unit (called class) is known as encapsulation. • In OOP we are capsuling our code not in a shell but in "Objects" & "Classes". • It hides all the internal details of an object from the outside world • It hides its data and methods from outside the world and only expose data and methods that are required. • It provides us maintainability, flexibility and extensibility to our code. • Encapsulation allows developers to build objects that can be changed without affecting the client code that uses them
  • 22. • The data is not accessible to the outside world and only those functions which are wrapped in the class can access it. • These functions provide the interface between the object's data and the program. • This insulation of the data from direct access by the program is called data hiding.
  • 23. Data Abstraction • “The process of identifying common patterns that have systematic variations; an abstraction represents the common pattern and provides a means for specifying which variation to use" • An abstract class is a parent class that allows inheritance but can never be instantiated • Abstract classes contain one or more abstract methods that do not have implementation. • Abstract classes allow specialization of inherited classes.
  • 24. Data Abstraction contn… • Abstraction is a powerful means to tackle the complexity of programming by wrapping up and thus reducing the complexity of complex operations. • In this it display only the features that needed the user, and hide all other data • Through Abstraction all relevant data can be hide in order to reduce complexity and increase efficiency
  • 25. Polymorphism • Its the property in which a single object can take more than one form. • Single interface & multiple method is called polymorphism. • Polymorphism allows objects to be represented in multiple forms. • Polymorphism is a concept linked to inheritance and assures that derived class have the same function even though each derived class performs different operations Ex: • Function overloading (Static polymorphism / early binding). • Function overriding (dynamic polymorphism / late binding). • Polymorphism allows a client to treat different objects in the same way even if they were created from different classes and exhibit different behaviors.
  • 26. Polymorphism • Method Overloading - Method with same name but with different arguments is called method overloading. - Method Overloading forms compile-time polymorphism. • Method Overriding - Method overriding occurs when child class declares a method that has the same type arguments as a method declared by one of its super class. - Method overriding forms Run-time polymorphism.
  • 27. • Modularity -The modularity of object-oriented programming means that the valid components of a big program can each be implemented individually. -Different people can work on various classes. -Each execution task is isolated from the others. -A ``module'' is nothing more than a file containing source code. - Breaking a large (or even not-so-large) program into different files is a convenient way of splitting it into manageable pieces. -Each piece can be worked on independently and compiled alone, then integrated with other pieces when the program is linked
  • 28. Delegation Delegation allows the behavior of an object to be defined in terms of the behavior of another object. ie , Delegation is alternative to class inheritance. • Delegation is a way of making object composition as powerful as inheritance. • In delegation, two objects are involved in handling a request: -A receiving object delegates operations to its delegate. -This is analogous to the child classes sending requests to the parent classes.
  • 29. • When an object receives a request, the object can either handle the request itself or pass the request on to a second object to do the work. • If the object decides to pass the request on, you say that the object has forwarded responsibility for handling the request to the second object.
  • 30. Inheritance • Inheritance is the property in which, a derived class acquires the attributes of its base class. • you can create or 'inherit' your own class (derived class), using an existing class (base class). You can use the Inherits keyword for this. • In OOP, a parent class can inherit its behavior and state to children classes. • This concept was developed to manage generalization and specialization in OOP and is represented by a is-a relationship.
  • 31. *The concept of generalization in OOP means that an object encapsulates common state an behavior for a category of objects. *The general object in this sample is the geometric shape. *Most geometric shapes have area, perimeter, and color. *The concept of specialization in OOP means that an object can inherit the common state and behavior of a generic object; however, each object needs to define its own special and particular state an behavior
  • 32. The Shape class is the parent class. Square, Rectangle, and Circle are derived classes that inherit from Shape. The triangle-connector in the diagram represents an is-a relationship.
  • 33. Imports System Class Human 'This is something that all humans do Public Sub Walk() Console.Writeline ("Walking") End Sub End Class ‘A Programmer is a Human Class Programmer Inherits Human 'We already have the above Walk() function 'This is something that all programmers do ;) Public Sub StealCode() Console.Writeline ("Stealing code") End Sub End Class
  • 34. • Example Program for class Public Class Example Private _value As Integer Public Sub New() _value = 2 End Sub Public Function Value() As Integer Return _value * 2 End Function End Class Module Module1 Sub Main() Dim x As Example = New Example() Console.WriteLine (x.Value()) End Sub End Module -----------(out put =4)
  • 35. Program that uses Inherits keyword [VB.NET] Class A Public _value As Integer Public Sub Display() Console.WriteLine(_value) End Sub End Class Class B : Inherits A Public Sub New(ByVal value As Integer) MyBase._value = value End Sub End Class Class C : Inherits A Public Sub New(ByVal value As Integer) MyBase._value = value * 2 End Sub End Class
  • 36. Module Module1 Sub Main() Dim b As B = New B(5) b.Display() Dim c As C = New C(5) c.Display() End Sub End Module
  • 37. • Imports System public Class Circle Public Radius As Double Public Function CalculateDiameter() As Double Return Radius * 2 End Function Public Function CalculateCircmuference() As Double Return CalculateDiameter() * 3.14159 End Function Public Function CalculateArea() As Double Return Radius * Radius * 3.14159 End Function End Class
  • 38. Public Class Exercise Public Sub Main() Dim circ As Circle = New Circle circ.Radius = 25.84 Console.WriteLine(" -=- Circle Characteristics -=-") Console.WriteLine("Radius: {0} ", circ.Radius) Console.WriteLine("Diameter:{0} ",circ.CalculateDiameter()) Console.WriteLine("Circumference:{0} ", circ.CalculateCircmuference()) Console.WriteLine("Area: {0} " & vbCrLf, circ.CalculateArea()) End Sub End Class
  • 39. • Result • -=- Circle Characteristics -=- Radius : 25.55 Diameter : 51.1 Circumference: 160.535249 Area : 2050.837805975
  • 40. • Advantages of OOP Object-Oriented Programming has the following advantages over conventional approaches: • OOP provides a clear modular structure for programs which makes it good for defining abstract data types where implementation details are hidden and the unit has a clearly defined interface. • OOP makes it easy to maintain and modify existing code as new objects can be created with small differences to existing ones. • OOP provides a good framework for code libraries where supplied software components can be easily adapted and modified by the programmer. This is particularly useful for developing graphical user interfaces.