Sei sulla pagina 1di 8

Procedure Oriented Programming (POP):-In POP Each problem to be solved is divided in to small number of functions.

In a large program it is very difficult to identify what data is used by which function. In the case of global data which function changed the value of global variable is hard to detect. Even more POP does not model real world problems very well. Thats why we need Another Programming Technique that solves these problems. Main Drawbacks: 1. POP does not model real world problems very well. 2. In a large program it is very difficult to identify what data is used by which function. In the case of global data which function changed the value of global variable is hard to detect Some characteristics exhibited by procedure-oriented programming are: 1. Emphasis is on doing things (algorithms) or code centric design. 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.

Object Oriented Programming (OOP):- Object oriented programming (oop) treats data as a critical element in the program development and does not allow it to flow freely around the system. It ties data more closely to the function that operate on it, and protect it form modification from outside functions. Oop allows decomposition of a problem into a number of entities called objects and then builds data and functions around those objects. The organization of data and functions in object oriented program is shown as

Definition of OOP: Object-oriented programming 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 Some of the striking features of object-oriented programming are: 1. Emphasis is on data rather than procedure or data centric design. 2. Programs are divided into what are known as objects. 3. Data structures are designed such that they characterize the objects. 4. Functions that operate on the data of an object are tied 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. 7. New data and functions can be easily added whenever necessary. BASIC CONCEPTS IN OOP . 1. Object 2. Class 3. Data abstraction 4. Encapsulation. 5. Inheritance 6. Polymorphism 7. Dynamic binding. 8. Message passing. Object : Object are the basic run-time entities in an object-oriented system. They may represent a person, a place a bank account, a table of data or any item that the program has to handle. Programming problem is analyzed in terms of objects and the nature of communication between them. Objects take up space in the memory & have an associated address like structure in c. When a program executes, the object interacts by sending

messages to one another. Ex. If there are two objects .customer. and .account. Then the customer object may send a message to account object requesting for the bank balance. Thus each object contains data, and code to manipulate the data.

Class The entire set of data and code of an object can be made a user-defined data type with the help of a class. Objects are actually variable of the type class. Once a class has been defined, we can create any number of objects belonging to that class. Thus a class is collection of objects of similar type. Classes are user defined data types and behaves like the built in type of a programming language.

Data abstraction Abstraction refers to the act of representing essential features without including the background details or explanations. Classes use the concept of abstraction and are defined as a list of abstract attributes such as size, weight and coast, and functions to operate on these attributes.

Encapsulation The wrapping up of data and functions into a single unit called class is known as encapsulation. 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 objects data and the program. This insulation of the data from direct access by the program is called data hiding or

information hiding. Inheritance i) Inheritance is the process by which object of one class acquire the properties of objects of another class. ii) In OOPs, the concept of inheritance provides the idea of reusability. This means that we can add additional features to an existing class without modifying it. iii) This is possible by deriving a new class from the existing one. The new class will have combined features of both the classes. Polymorphism i) Polymorphism is important oops concept. It means ability to take more than one form. ii) Polymorphism means SINGLE NAME MULTIPLE BEHAVIOR iii) In polymorphism an operations may shows different behavior in different instances. The behavior depends upon the type of data used in the operation. For Ex- Operation of addition for two numbers, will generate a sum. If the operands are strings, then the operation would produce a third string by concatenation. iv) The process of making an operator to show different behavior in different instance is called as operator overloading. C++ support operator overloading.

Dynamic Binding i) Binding referes to the linking of a procedure call to the code to be executed in response to the call. ii) Dynamic binding means that the code associated with a given procedure call is not known until the time of the call at run time.

Message Passing OOP consist of a set of objects that communicate with each other. Message passing involves following steps i) Creating classes that define objects and their behavior ii) Creating objects from class definitions and iii) Establishing communication among objects. A message for an object is a request for execution of a procedure & therefore will invoke a function in the receiving object that generates the desired result. Message passing involves specifying the name of the object, the name of the function i.e. message and the information to be sent. Benefits of OOP: 1. Through inheritance, we can eliminate redundant code and extend the use of existing classes. 2. We can build programs from the standard working modules that communicate with another, rather than having to start writing code from scratch. This leads to saving of development time and higher productivity. 3. The principle of data hiding helps the programmer to build secure programs that can not be invaded by code in other parts of the program. 4. It is possible to map objects in the problem domain to those in the program. 5. It is easy to partition the work in a project based on objects. 6. The data-centered design approach enables us to capture more details of a model in implementable form. 7. Object-oriented systems can be easily upgraded from small to large systems. 8. Message passing techniques for communication between objects makes the interface descriptions with external systems much simpler. 9. Software complexity can be easily managed.

Applications of OOP: The promising areas for application of OOP include: Real-time systems Simulation and modeling Object-oriented databases Hypertext, hypermedia and expert text AI and expert systems Neural networks and parallel programming Decision support and office automation systems CIM/CAM/CAD systems

Potrebbero piacerti anche