KEMBAR78
IET307 OOP - object oriented programming concepts.pptx
Object Oriented Programming
OOP Concepts
Comparison of OOP & POP
Procedure Oriented Programming
• Problem is viewed as a sequence of things to
be done such as reading, calculating and
printing
• A number of functions are written to
accomplish various tasks
• Many important data items are placed as
global – they are vulnerable to accidental
changes by functions
Typical structure of procedure oriented
programs
Relationship Between Data and Functions in
POP
Procedure Oriented Programming
• In a large program, it is very difficult to
identify which data belong to which function
• For an external data structure to be revised, all
functions that access the data need to be
revised
• This increases opportunity for bugs to creep in
• POPs do not model real world problems very
well
Comparison of OOP and POP
Procedure Oriented Programming Object Oriented Programming
Program is divided into small parts
called functions.
Program is divided into parts called
objects.
Importance is not given to data but to
functions as well as sequence of
actions to be done.
Importance is given to the data rather
than procedures or functions
Follows Top Down approach. Follows Bottom Up approach
Does not have any access specifier. Has access specifiers named Public,
Private and Protected
Data can move freely from function to
function in the system
Objects can move and communicate with
each other through member functions.
Comparison of OOP and POP contd..
Procedure Oriented Programming Object Oriented Programming
To add new data and function is not easy Provides an easy way to add new data and
function.
Most function uses Global data for
sharing that can be accessed freely from
function to function in the system.
Data can not move easily from function to
function. It can be kept public or private,
so we can control the access of data.
Does not have any proper way for hiding
data; so it is less secure.
Provides Data Hiding. which gives more
security to data
Overloading is not possible. Overloading is possible in the form of
Function Overloading and Operator
Overloading
Example of Procedure Oriented
Programming languages :
C, FORTRAN, Pascal, VB
Example of Object Oriented Programming
Languages :
C++, JAVA, Simula, Smalltalk, VB.NET,
C#.NET, Ada
Object Oriented Programming Definition
OOP can be defined as an approach
that provides a way of modularizing
programs by creating partitioned
memory area for both data and
functions, that can be used as
templates for creating copies of such
modules on demand.
Features of Object Oriented Programming
• Treats data as critical element and does not allow it to flow
freely around the system.
• Programs are divided into entities known as objects
• Data and functions are built around these objects
• Data and the functions that operate on them are tied
together
• Data is hidden and cannot be accessed by external functions
• Objects may communicate with each other through functions
• New data and functions can be easily added whenever
necessary
Fundamental Concepts of OOP
• Object
• Class
• Method
• Modularity
• Data abstraction
• Encapsulation
• Hierarchy
• Inheritance
• Polymorphism
• Dynamic Binding
• Message Passing
• Reusability
• Delegation
• Genericity
Object
• Is a partitioned area of computer memory that stores
data and the set of operations that can access that
data
• Basic run-time entities in OOP
• Represent real-world entities like a person, a bank
account , a list etc.
• Programming problem is analyzed in terms of objects
and the nature of communication between them
• Objects take up space in memory and have an
associated address
Class
• Is a group of objects having identical properties,
common behaviour and shared relationship
• Is a user-defined datatype
• The entire group of data and code of an object
is built using class - class is a model of the
object
• Objects are nothing but variables of the type
class
Method
• An operation required for an object or entity
when coded in a class is called a method
• Class member functions
• Data members of any class uses its member
functions or methods to perform operation
Modularity
• Modularity refers to an organizing structure in
which different components of a software
system are divided into separate functional
units.
• The various components can work together to
form a single functioning unit; but sometimes
they can perform alone as a complete
function, if not connected with each other.
Data Abstraction
• Refers to representing essential features
without including background details.
• Classes use the concept of abstraction and are
defined as a list of abstract attribute ( data
members) and functions ( member functions)
to operate on these attributes.
Encapsulation
• This is the wrapping up of data and functions
into a single unit ( called class ) .
• This restricts access to data from the outside
world; only those functions wrapped in the
class can access it
• This insulation of data from direct access by
the program is called data hiding
Hierarchy
• Hierarchy refers to an organizational structure in
which items are ranked in a specific manner, usually
according to levels of importance.
• Data hierarchy is the structure and organization of
data in a database
• Class hierarchy refers to a family of classes obtained
through inheritance
Inheritance
• Process by which objects of one class acquire the
properties of objects of another class
• It supports the concept of hierarchical classification
• A derived class shares common characteristics with
the base class
• Through inheritance reusability is achieved
• Additional features can be added to an existing
class without modifying it or having to rewrite its
code in the new class
Polymorphism
• Means the ability to take more than one form
• An entity may exhibit different behaviours in different
instances
• In C++, polymorphism is achieved through operator
overloading and function overloading
• Making an operator with operands of basic datatype
do the same operation with user-defined datatypes is
called operator overloading
• Using the same function name for defining different
function is called function overloading
Dynamic Binding
• Binding is the linking of a function call to the
function to be executed in response to the call
• Normally, function calls are linked to specific
functions during compile time (early binding).
• In dynamic binding (late binding), the function
code associated with a given call is not known
until the time of call during run-time.
• It is associated with polymorphism
Message Passing
• Object oriented programs consist of a set of
objects that communicate with each other
• Objects communicate by passing messages
• Message for an object is a request for execution
of a procedure and will invoke a function in the
receiving object
• Message passing involves specifying the name of
the object, the name of the function and the
information to be sent
Reusability
• OOP allows reusability of classes by extending
their features to other classes using
inheritance.
• Reusability saves time and effort
Delegation
• Two classes can be joined by either
inheritance
or by
delegation
In inheritance, one class is derived from another
In delegation, object of one class is used as data
member of another class
Genericity
• This feature allows declaration of variables
without specifying exact data type
• Compiler identifies the data type at run time
• A function that can be used for any type of
data can be created
• Template feature in C++ allows generic
programming
Advantages of OOP
• Object oriented programs can be easily upgraded from
small to large systems
• Through inheritance, redundant code can be
eliminated and extend the use of existing classes
• Data hiding facilitates design and development of
secure programs that cannot be invaded by code in
other parts of the program
• Easy to partition the work in a project based on objects
• Software complexity can be easily managed
Applications of OOP
The promising areas of application of OOP include
• Simulation and modelling
• Object –oriented databases
• AI and expert systems
• Neural network and parallel programming
• Decision support and office automation systems
• CIM/CAD/CAM systems
• Real-time systems
• Hypertext, hypermedia and expertext

IET307 OOP - object oriented programming concepts.pptx

  • 1.
    Object Oriented Programming OOPConcepts Comparison of OOP & POP
  • 2.
    Procedure Oriented Programming •Problem is viewed as a sequence of things to be done such as reading, calculating and printing • A number of functions are written to accomplish various tasks • Many important data items are placed as global – they are vulnerable to accidental changes by functions
  • 3.
    Typical structure ofprocedure oriented programs
  • 4.
    Relationship Between Dataand Functions in POP
  • 5.
    Procedure Oriented Programming •In a large program, it is very difficult to identify which data belong to which function • For an external data structure to be revised, all functions that access the data need to be revised • This increases opportunity for bugs to creep in • POPs do not model real world problems very well
  • 6.
    Comparison of OOPand POP Procedure Oriented Programming Object Oriented Programming Program is divided into small parts called functions. Program is divided into parts called objects. Importance is not given to data but to functions as well as sequence of actions to be done. Importance is given to the data rather than procedures or functions Follows Top Down approach. Follows Bottom Up approach Does not have any access specifier. Has access specifiers named Public, Private and Protected Data can move freely from function to function in the system Objects can move and communicate with each other through member functions.
  • 7.
    Comparison of OOPand POP contd.. Procedure Oriented Programming Object Oriented Programming To add new data and function is not easy Provides an easy way to add new data and function. Most function uses Global data for sharing that can be accessed freely from function to function in the system. Data can not move easily from function to function. It can be kept public or private, so we can control the access of data. Does not have any proper way for hiding data; so it is less secure. Provides Data Hiding. which gives more security to data Overloading is not possible. Overloading is possible in the form of Function Overloading and Operator Overloading Example of Procedure Oriented Programming languages : C, FORTRAN, Pascal, VB Example of Object Oriented Programming Languages : C++, JAVA, Simula, Smalltalk, VB.NET, C#.NET, Ada
  • 8.
    Object Oriented ProgrammingDefinition OOP can be defined as an approach that provides a way of modularizing programs by creating partitioned memory area for both data and functions, that can be used as templates for creating copies of such modules on demand.
  • 9.
    Features of ObjectOriented Programming • Treats data as critical element and does not allow it to flow freely around the system. • Programs are divided into entities known as objects • Data and functions are built around these objects • Data and the functions that operate on them are tied together • Data is hidden and cannot be accessed by external functions • Objects may communicate with each other through functions • New data and functions can be easily added whenever necessary
  • 10.
    Fundamental Concepts ofOOP • Object • Class • Method • Modularity • Data abstraction • Encapsulation • Hierarchy • Inheritance • Polymorphism • Dynamic Binding • Message Passing • Reusability • Delegation • Genericity
  • 11.
    Object • Is apartitioned area of computer memory that stores data and the set of operations that can access that data • Basic run-time entities in OOP • Represent real-world entities like a person, a bank account , a list etc. • Programming problem is analyzed in terms of objects and the nature of communication between them • Objects take up space in memory and have an associated address
  • 12.
    Class • Is agroup of objects having identical properties, common behaviour and shared relationship • Is a user-defined datatype • The entire group of data and code of an object is built using class - class is a model of the object • Objects are nothing but variables of the type class
  • 13.
    Method • An operationrequired for an object or entity when coded in a class is called a method • Class member functions • Data members of any class uses its member functions or methods to perform operation
  • 14.
    Modularity • Modularity refersto an organizing structure in which different components of a software system are divided into separate functional units. • The various components can work together to form a single functioning unit; but sometimes they can perform alone as a complete function, if not connected with each other.
  • 15.
    Data Abstraction • Refersto representing essential features without including background details. • Classes use the concept of abstraction and are defined as a list of abstract attribute ( data members) and functions ( member functions) to operate on these attributes.
  • 16.
    Encapsulation • This isthe wrapping up of data and functions into a single unit ( called class ) . • This restricts access to data from the outside world; only those functions wrapped in the class can access it • This insulation of data from direct access by the program is called data hiding
  • 17.
    Hierarchy • Hierarchy refersto an organizational structure in which items are ranked in a specific manner, usually according to levels of importance. • Data hierarchy is the structure and organization of data in a database • Class hierarchy refers to a family of classes obtained through inheritance
  • 18.
    Inheritance • Process bywhich objects of one class acquire the properties of objects of another class • It supports the concept of hierarchical classification • A derived class shares common characteristics with the base class • Through inheritance reusability is achieved • Additional features can be added to an existing class without modifying it or having to rewrite its code in the new class
  • 19.
    Polymorphism • Means theability to take more than one form • An entity may exhibit different behaviours in different instances • In C++, polymorphism is achieved through operator overloading and function overloading • Making an operator with operands of basic datatype do the same operation with user-defined datatypes is called operator overloading • Using the same function name for defining different function is called function overloading
  • 20.
    Dynamic Binding • Bindingis the linking of a function call to the function to be executed in response to the call • Normally, function calls are linked to specific functions during compile time (early binding). • In dynamic binding (late binding), the function code associated with a given call is not known until the time of call during run-time. • It is associated with polymorphism
  • 21.
    Message Passing • Objectoriented programs consist of a set of objects that communicate with each other • Objects communicate by passing messages • Message for an object is a request for execution of a procedure and will invoke a function in the receiving object • Message passing involves specifying the name of the object, the name of the function and the information to be sent
  • 22.
    Reusability • OOP allowsreusability of classes by extending their features to other classes using inheritance. • Reusability saves time and effort
  • 23.
    Delegation • Two classescan be joined by either inheritance or by delegation In inheritance, one class is derived from another In delegation, object of one class is used as data member of another class
  • 24.
    Genericity • This featureallows declaration of variables without specifying exact data type • Compiler identifies the data type at run time • A function that can be used for any type of data can be created • Template feature in C++ allows generic programming
  • 25.
    Advantages of OOP •Object oriented programs can be easily upgraded from small to large systems • Through inheritance, redundant code can be eliminated and extend the use of existing classes • Data hiding facilitates design and development of secure programs that cannot be invaded by code in other parts of the program • Easy to partition the work in a project based on objects • Software complexity can be easily managed
  • 26.
    Applications of OOP Thepromising areas of application of OOP include • Simulation and modelling • Object –oriented databases • AI and expert systems • Neural network and parallel programming • Decision support and office automation systems • CIM/CAD/CAM systems • Real-time systems • Hypertext, hypermedia and expertext