Object Oriented Programming Unit-1 Basic Theory

  • Developments in software technology continue to be dynamic.
  • New tools and techniques are announced in quick succession.
  • This has forced the software engineers and industry to continuously look for new approaches to software design and development.
  • These rapid advances appear to have created a situation of crisis within the industry.

  • How to represent real-life entities of problems in system design?
  • How to design system with open interfaces?
  • How to improve the quality of software?
  • How to manage time schedules?
  • How to ensure reusability and extensibility of modules?
  • How to improve software productivity and decrease software cost?
  • How to develop modules that are tolerant of any changes in future?

  • Changes in data formats
  • Changes in user requirements
  • Changes in hardware
  • Less Efficiency
  • Not proper documentation
  • Not proper debugging

  • Correctness
  • Maintainability
  • Reusability
  • Openness and interoperability
  • Portability
  • Security
  • Integrity
  • User friendliness
    • Since the invention of the computer, many programming approaches have been tried.
    • such as
      • Modular programming
      • Top down programming
      • Bottom up programming
      • Structured programming
    • The primary motivation in each has been the concern to handle the increasing complexity or programs that are reliable and maintainable.
    • Structured programmning (C Language) became very popular and was the main technique of the 1980s. This language was a powerful tool that enabled programmers to write moderately complex programs fairly easily. However. as the programs grew larger, even this C language approach failed to show the desired results in terms of bug-free, easy-to-maintain, and reusable program.
    • Object-Oriented Programming (OOP) is an approach to program organization and development that attempts to eliminate some of the pitfalls of conventional programming methods by incorporating the best of structured programming features with several powerful new concepts. It is a new way of organizing and developing program and has nothing to with any particular language. However, not all language is are suitable to implement the OOP concepts easily.

    • Conventional programming, using high level languages such as COBOL, FORTRAN and C, is commonly known as procedure oriented programming (POP).
    • In the procedure-oriented approach, the 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 these tasks.
    • The technique of hierarchical decomposition has been used to specify tasks to be completed for solving a problem.
    • POP1
    • Normally, programmer uses a flowchart to organize these actions and represent the flow of control from one action to another.
    • However, during programming, programmer concentrates on the development of functions and gives very little attention to the data that are being used by various functions.
    • In a multi function program, many important data items are placed as global so that they may be accessed by all the functions. Each function may have its own local data. POP2
    • Global data are easily change by a function. In a large program it is very difficult to identify what data is used by which function. In such case there is need to use an external data structure, we also need to monitor all functions that access the data. This provides an opportunity for bugs to creep in.
    • Another serious drawback with the procedural approach is that it does not model real world problems very well. This is because functions are action- oriented and do not really corresponding to the elements of the problem.

    1. Emphasis is on doing things (algorithms).
    2. Large programs are divided into smaller programs known as functions.
    3. Most of the functions share global data.
    4. Data move openly around the system from function to function.
    5. Functions transform data from one form to another.
    6. Employs top down approach in program design.

    • Motivation behind OOP
    • In the Procedural Oriented Approach, Data flow freely around the system and easily can modify from outside function.
    • Hence, there is a need of protection on freely data flow and protects data from accidental modification from outside functions.

    • In OOP, data is treated as a critical element in the program development and there is system in which data can not flow freely around the program.
    • Actually, data are kept more closely to the function that operate on it and protect it from outside function to minimize accidental modification.
    • OOP allows decomposition of a program into a number of entities called objects instead of functions and building data and functions around these objects.

    1. Force is on data rather than procedure
    2. Programs are divided into objects rather than functions.
    3. Data Structures are designed such that they characterize the objects.
    4. Functions that operate on the data of an object are tried together in the data structure.
    5. Data is hidden and cannot be accessed by external functions.
    6. Objects may communicate with each other through functions only.
    7. New data and functions can be easily added whenever necessary.
    8. Follows bottom-up approach in program design instead of top-down approach.

    It is 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.

    Its basic concepts include:
    1. Objects,
    2. Classes,
    3. Data Abstraction,
    4. Data Encapsulation,
    5. Inheritances,
    6. Polymorphism,
    7. Dynamic Binding and
    8. Message Passing

    Objects
    • They are the basic runtimes entities in an object oriented system
    • They may represent a person, a place, a back account or any item that the program has to handle.
    ClassObject
    Classes
    1. Object contains data and code to manipulate that data.
    2. The entire set of data and code of an object can be made a user-defined data type with the help of class.
    A class is a 3-Compartment Box encapsulating Data and Functions
    1. Class name (or identifier); identifies the class
    2. Data Members or Variables (or attributes, states, fields): contain the static attributes of the class
    3. Member Functions (or methods, behaviors, operations): contain the dynamic operations of the class.

    • The wrapping up of data and functions into a single unit is known as encapsulation.
    • The data is not accessible to the outside world, only those function which are wrapped in, they can only access it.
    • These functions provide the interface between the object's data and the function.
    • This insulation pf the data from direct access by the program is called data hiding or information hiding.

    1. Abstraction refers to the act of representing essential features without including the background details or explanations.
    2. Classes use the concept of abstraction and are defined abstract attributes and functions to operate on these attributes.
    3. The attributes are called data members because they hold information.
    4. The functions that operate on these data are called methods or member functions.
    5. As the classes use the concept of data abstraction, therefore classes are known as Abstract Data Types (ADT).
    6. ADT is type is a data type that is defined by the programmer, not the language.

    An ADT specifies:
    1. a. Data Stored
    2. b. Operations on the data
    3. c. Error Conditions associated with operations

    1. Inheritance is the process by which objects of one class acquire the properties of objects of another class.
    2. In OOP, the concept of inheritance provides the idea of reusability.
    3. Using Inheritance property, additional features can be added to an existing class without modifying it.
    Inheritance

    1. It is a Greek term, means to ability to take more than one form.
    2. An operation may exhibits different behaviors indifferent instances.
    3. The behavior depends upon the type of data used in the operation.
    4. The process of making an operator to exhibit different behavior in different instances is known as op0erator overloading.

    1. C++ provides facility to specify that the compiler should match function calls with the correct definition at the run time.
    2. This is called dynamic binding or late binding or run-time binding.
    3. Dynamic binding is achieved using virtual functions.

    1. Objects can communicate with each others by passing message same as people passing message with each other.
    2. Objects can send or receive message or information.
    3. Message passing involves name of object, name of function (message) and information to be send.
    4. For example
      1. student.mark(name).
        Here, student is object, mark is message,name is information.

    • Through inheritance, redundant code can be eliminated and extend the use of existing classes which is not possible in procedure oriented approach.
    • Program can be built from the standard working modules that communicate with one another, rather than having to start writing the code from scratch which happens procedure oriented approach. This leads to saving of development time and higher productivity.
    • The principle of data hiding helps the programmer to build secure programs that cannot be invaded by code in other parts of the program.
    • It is possible to have multiple instances of object to co-exist without any interference.
    • It is possible to map objects in the problem domain to those in the program.
    • It is easy to partition the work in a project based on objects.
    • The data-centered design approach enables us to capture more details of a model in implementable from.
    • Object oriented systems can be easily upgraded from small to large systems.
    • Message passing techniques for communication between objects makes the interface descriptions with external systems much simpler.
    • Software complexity can be easily managed.

    While Simula is credited as the first object-oriented programming language, the most popular OOP languages are:
    C++, Java, Python, Visual Basic .NET, Ruby, Scala, PHP, Curl, Delphi, Eiffel

    1. Real time system
    2. Simulation and Modeling
    3. Object-Oriented Databases
    4. Hypertext, hypermideia and expertext
    5. AI and expert system
    6. Neural Network and Parallel Programming
    7. Decision Support and Office Automation Systems
    8. Computer integrated manufacturing (CIM)
    9. Computer-Aided Design(CAD)
    10. Computer-Aided Manufacturing (CAM)