SUBJECT: Object Oriented Programming & Methodology(OOPM)
(CS305)
                      UNIT _1
Introduction to object oriented programming
                  Taught by:Mrs. Ruchi Saxena
                                                           1
               POINTS TO COVER IN UNIT_1
1. Introduction to Object Oriented Thinking
2. Object Oriented Programming Comparison with Procedural
   Programming
3. features of Object oriented paradigm– Merits and demerits
   of OO methodology
4. Object model
5. Elements of OOPS
6. IO processing.
                                                               2
                  Introduction to Object Oriented Thinking
• Object-Oriented Programming (OOP) is the term used to describe a
  programming approach based on objects and classes.
• The object-oriented paradigm allows us to organise software as a collection
  of objects that consist of both data and behaviour.
• This is in contrast to conventional functional programming practice that
  only loosely connects data and behaviour.
• Since the 1980s the word 'object' has appeared in relation to programming
  languages, with almost all languages developed since 1990 having object-
  oriented features.
• It is widely accepted that object-oriented programming is the most
  important and powerful way of creating software.
                                                                                3
The object-oriented programming approach encourages:
• Modularisation: where the application can be decomposed into modules.
• Software re-use: where an application can be composed from existing and
   new modules.
An object-oriented programming language generally supports five main
   features:
1. Classes
2. Objects
3. Classification
4. Polymorphism
5. Inheritance
                                                                            4
             Object Oriented Programming Comparison with
                        Procedural Programming
• Both are programming processes whereas OOP stands for “Object
  Oriented Programming” and POP stands for “Procedure Oriented
  Programming”.
• Both are programming languages that use high-level programming to solve
  a problem but using different approaches.
• These approaches in technical terms are known as programming
  paradigms.
• A programmer can take different approaches to write a program because
  there’s no direct approach to solve a particular problem.
                                                                            5
Fig. programming language categories
                                       6
         What is Procedure Oriented Programming (POP)?
• POP follows a step-by-step approach to break down a task into a collection
  of variables and routines (or subroutines) through a sequence of
  instructions.
• Each step is carried out in order in a systematic manner so that a computer
  can understand what to do.
•   The program is divided into small parts called functions and then it
  follows a series of computational steps to be carried out in order.
• It follows a top-down approach to actually solve a problem, hence the
  name.
• Procedures correspond to functions and each function has its own purpose.
• Dividing the program into functions is the key to procedural programming.
• So a number of different functions are written in order to accomplish the
  tasks.
                                                                                7
              What is Object Oriented Programming (OOP)?
OOP is a high-level programming language where a program is divided into
  small chunks called objects using the object-oriented model, hence the
  name. This paradigm is based on objects and classes.
• Object – An object is basically a self-contained entity that accumulates
  both data and procedures to manipulate the data. Objects are merely
  instances of classes.
• Class – A class, in simple terms, is a blueprint of an object which defines
  all the common properties of one or more objects that are associated with
  it. A class can be used to define multiple objects within a program.
                                                                                8
     • The OOP paradigm mainly eyes on the data rather than the algorithm
        to create modules by dividing a program into data and functions that
        are bundled within the objects.
•   The modules cannot be modified when a new object is added restricting
    any non-member function access to the data. Methods are the only way to
    assess the data.
•   Objects can communicate with each other through same member functions.
    This process is known as message passing.
•    This anonymity among the objects is what makes the program secure.
•   A programmer can create a new object from the already existing objects by
    taking most of its features thus making the program easy to implement and
    modify.
                                                                                9
Fig. difference between oop and pop
                                      10
                          Features of Object oriented paradigm
Object-oriented programming (OOP) is a programming paradigm based upon objects
   (having both data and methods) that aims to incorporate the advantages of modularity
   and reusability. Objects, which are usually instances of classes, are used to interact
   with one another to design applications and computer programs.
The important features of object–oriented programming are −
• Bottom–up approach in program design
• Programs organized around objects, grouped in classes
• Focus on data with methods to operate upon object’s data
• Interaction between objects through functions
• Reusability of design through creation of new classes by adding features to existing
   classes
• Some examples of object-oriented programming languages are C++, Java, Smalltalk,
   Delphi, C#, Perl, Python, Ruby, and PHP.
Grady Booch has defined object–oriented programming as “a method of
   implementation in which programs are organized as cooperative collections of
   objects, each of which represents an instance of some class, and whose classes are
   all members of a hierarchy of classes united via inheritance relationships”.
                                                                                            11
                         Benefits Of OOP/Merits of oop
•  Two examples of popular object-oriented programming languages are Java and C++.
   Some other well-known object-oriented programming languages include Objective C,
   Perl, Python, Javascript, Simula, Modula, Ada, Smalltalk, and the Common Lisp
   Object Standard.
Some of the advantages of object-oriented programming include:
 Reusability
 Extensibility
 Decomposability
 Compos ability
 Understandability
 Security
1.Improved software-development productivity: Object-oriented programming is
   modular, as it provides separation of duties in object-based program development. It is
   also extensible, as objects can be extended to include new attributes and behaviors.
   Objects can also be reused within an across applications. Because of these three factors
   – modularity, extensibility, and reusability – object-oriented programming provides
   improved software-development productivity over traditional procedure-based
   programming techniques.
                                                                                         12
2. Improved software maintainability: For the reasons mentioned above,
   objectoriented software is also easier to maintain. Since the design is modular,
   part of the system can be updated in case of issues without a need to make
   large-scale changes.
3.Faster development: Reuse enables faster development. Object-oriented
   programming languages come with rich libraries of objects, and code
   developed during projects is also reusable in future projects.
4. Lower cost of development: The reuse of software also lowers the cost of
   development. Typically, more effort is put into the object-oriented analysis
   and design, which lowers the overall cost of development.
5. Higher-quality software: Faster development of software and lower cost of
   development allows more time and resources to be used in the verification of
   the software. Although quality is dependent upon the experience of the teams,
   objectoriented programming tends to result in higher-quality software.
                                                                                  13
                                  Demerits of oop
1.Steep learning curve: The thought process involved in object-oriented programming
    may not be natural for some people, and it can take time to get used to it. It is
    complex to create programs based on interaction of objects. Some of the key
    programming techniques, such as inheritance and polymorphism, can be
    challenging to comprehend initially.
2. Larger program size: Object-oriented programs typically involve more lines of
    code than procedural programs.
3. Slower programs: Object-oriented programs are typically slower than
    procedurebased programs, as they typically require more instructions to be
    executed.
4. Not suitable for all types of problems: There are problems that lend themselves
    well to functional-programming style, logic-programming style, or procedure-based
    programming style, and applying object-oriented programming in those situations
    will not result in efficient programs.
                                                                                        14
                          Object model
• An object model is a logical interface, software or system that is modeled
  through the use of object-oriented techniques. It enables the creation of
  an architectural software or system model prior to development or
  programming.
• An object model is part of the object-oriented programming (OOP)
  lifecycle.
• Object model examples include:
  Document Object Model (DOM): A set of objects that provides a
  modeled representation of dynamic HTML and XHTML-based Web
  pages
    Component Object Model (COM): A proprietary Microsoft software
  architecture used to create software components
                                                                               15
                                                         POLYMORPHISM
INHERITANCE
                           Elements/
                         Characteristic of
                              OOPS
 ENCAPSULATION                                        ABSTRACTION
              Fig. Elements/ Characteristic of OOPS
                                                                        16
                                 IO processing
C++ comes with libraries which provides us many ways for performing input
  and output. In C++ input and output is performed in the form of sequence
  of bytes or more commonly known as streams.
• Input Stream: If the direction of flow of bytes is from device(for
  example: Keyboard) to the main memory then this process is called input.
• Output Stream: If the direction of flow of bytes is opposite, i.e. from
  main memory to device( display screen ) then this process is called output.
• Header files available in C++ for Input – Output operation are:
• iostream: iostream stands for standard input output stream. This header
  file contains definitions to objects like cin, cout, cerr etc.
                                                                                17
• iomanip: iomanip stands for input output manipulators. The methods
  declared in this files are used for manipulating streams. This file contains
  definitions of setw, setprecision etc.
• fstream: This header file mainly describes the file stream. This header file
  is used to handle the data being read from a file as input or data being
  written into the file as output.
• In C++ articles, these two keywords cout and cin are used very often for
  taking inputs and printing outputs. These two are the most basic methods of
  taking input and output in C++. For using cin and cout we must include the
  header file iostream in our program.
                                                                                 18
QUICK REVISION!
  ANY QUERY?
  THANKYOU
                  19